forked from rajeshpillai/HelpDoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpRepository.cs
More file actions
51 lines (42 loc) · 1.2 KB
/
HelpRepository.cs
File metadata and controls
51 lines (42 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Biggy;
using HelpDoc.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Biggy.Extensions;
namespace HelpDoc.Data
{
public class HelpDb
{
static string DB_PATH = HttpContext.Current.Server.MapPath("~/files");
public BiggyList<Post> Posts = new BiggyList<Post>(DB_PATH);
public BiggyList<Tag> Tags = new BiggyList<Tag>(DB_PATH);
public BiggyList<Section> Sections = new BiggyList<Section>(DB_PATH);
public BiggyList<AppUser> Users = new BiggyList<AppUser>(DB_PATH);
public bool Create(Post post)
{
Posts.Add(post);
Posts.Save();
return true;
}
public bool Update(Post post)
{
var find = Posts.First<Post>(p => p.Id == post.Id);
Posts.Remove(find);
Posts.Add(post);
Posts.Save();
return true;
}
public void Delete(Post post)
{
Posts.Remove(post);
Posts.Save();
}
public List<Post> All ()
{
var posts = Posts.TryLoadFileData(DB_PATH + "/posts.json");
return posts;
}
}
}