Esempio n. 1
0
 public News GetNewsById(int id)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.News.Find(id));
     }
 }
Esempio n. 2
0
 public IEnumerable <DirectionIdea> GetUserIdeas(int userId)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.DirectionIdea.Where(i => i.UserId == userId).ToList());
     }
 }
Esempio n. 3
0
 public IEnumerable <Users> SearchByEmail(string fragment)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Users.Where(u => u.Email.Contains(fragment)).ToArray());
     }
 }
Esempio n. 4
0
 public IEnumerable <Project> GetAll()
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Project.ToList());
     }
 }
Esempio n. 5
0
 public List <Participating> GetParticipants(int projectId)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Participating.Where(p => p.ProjectId == projectId).ToList());
     }
 }
Esempio n. 6
0
 public Users GetUserById(int id)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Users.Where(u => u.Id == id).Include("DistrictNavigation").FirstOrDefault());
     }
 }
Esempio n. 7
0
 public bool IsParticipate(Participating participating)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Participating.FirstOrDefault(p => p.UserId == participating.UserId && p.ProjectId == participating.ProjectId) != null);
     }
 }
Esempio n. 8
0
 public bool IsUserVoted(Voting voting)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Voting.FirstOrDefault(v => v.UserId == voting.UserId && v.IdeaId == voting.IdeaId) != null);
     }
 }
Esempio n. 9
0
 public IEnumerable <News> GetAllNews()
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.News.ToList());
     }
 }
Esempio n. 10
0
 public Users GetUserBySnils(long snils)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Users.Where(u => u.Snils == snils).FirstOrDefault());
     }
 }
Esempio n. 11
0
 public IdeaComment GetCommentById(int id)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.IdeaComment.Find(id));
     }
 }
Esempio n. 12
0
 public IEnumerable <Users> SearchByFio(string fragment)
 {
     using (var db = new ActiveCitizenContext())
     {
         return(db.Users.Where(u => u.FirstName.Contains(fragment) || u.LastName.Contains(fragment) || u.Patronym.Contains(fragment)).ToArray());
     }
 }
Esempio n. 13
0
 public void AddProject(Project project)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Project.Add(project);
         db.SaveChanges();
     }
 }
Esempio n. 14
0
 public bool UpdateDirection(ProjectDirection direction)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Entry(db.ProjectDirection.Find(direction.Id)).CurrentValues.SetValues(direction);
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 15
0
 public bool EditUserProfile(Users user)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Entry(db.Users.Find(user.Id)).CurrentValues.SetValues(user);
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 16
0
 public bool RealiseIdea(int id)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.DirectionIdea.Find(id).IsRealised = true;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 17
0
 public bool UpdateUserRole(int userId, int role)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Users.Find(userId).Role = role;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 18
0
 public bool ConfirmUserEmail(int id)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Users.Find(id).IsConfirmedEmail = true;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 19
0
 public void AddUser(Users user)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
 }
Esempio n. 20
0
 public Users GetUserByEmail(string email)
 {
     using (var db = new ActiveCitizenContext())
     {
         var user = db.Users.Where(u => u.Email == email).Include("DistrictNavigation").FirstOrDefault();
         return(user);
     }
 }
Esempio n. 21
0
 public bool DeleteProject(int id)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Project.Remove(db.Project.Find(id));
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 22
0
 public bool ChangePassword(string email, string password)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Users.Where(u => u.Email == email).FirstOrDefault().Password = password;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 23
0
 public bool UpdateUserAvatar(int userId, string avatar)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Users.Find(userId).UserAvatar = avatar;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 24
0
 public bool EditNews(News news)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Entry(db.News.Find(news.Id)).CurrentValues.SetValues(news);
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 25
0
 public bool UpdateProject(Project project)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Entry(db.Project.Find(project.Id)).CurrentValues.SetValues(project);
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 26
0
 public bool DeleteUserAvatar(int userId)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Users.Find(userId).UserAvatar = null;
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 27
0
 public bool DeleteDirection(ProjectDirection direction)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.Remove(db.ProjectDirection.Find(direction.Id));
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 28
0
 public bool AddDirection(ProjectDirection direction)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.ProjectDirection.Add(direction);
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 29
0
 public bool AddNews(News news)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.News.Add(news);
         return(db.SaveChanges() > 0);
     }
 }
Esempio n. 30
0
 public bool AddComment(IdeaComment comment)
 {
     using (var db = new ActiveCitizenContext())
     {
         db.IdeaComment.Add(comment);
         db.DirectionIdea.Find(comment.IdeaId).CountOfComments++;
         return(db.SaveChanges() > 1);
     }
 }