public News GetNewsById(int id) { using (var db = new ActiveCitizenContext()) { return(db.News.Find(id)); } }
public IEnumerable <DirectionIdea> GetUserIdeas(int userId) { using (var db = new ActiveCitizenContext()) { return(db.DirectionIdea.Where(i => i.UserId == userId).ToList()); } }
public IEnumerable <Users> SearchByEmail(string fragment) { using (var db = new ActiveCitizenContext()) { return(db.Users.Where(u => u.Email.Contains(fragment)).ToArray()); } }
public IEnumerable <Project> GetAll() { using (var db = new ActiveCitizenContext()) { return(db.Project.ToList()); } }
public List <Participating> GetParticipants(int projectId) { using (var db = new ActiveCitizenContext()) { return(db.Participating.Where(p => p.ProjectId == projectId).ToList()); } }
public Users GetUserById(int id) { using (var db = new ActiveCitizenContext()) { return(db.Users.Where(u => u.Id == id).Include("DistrictNavigation").FirstOrDefault()); } }
public bool IsParticipate(Participating participating) { using (var db = new ActiveCitizenContext()) { return(db.Participating.FirstOrDefault(p => p.UserId == participating.UserId && p.ProjectId == participating.ProjectId) != null); } }
public bool IsUserVoted(Voting voting) { using (var db = new ActiveCitizenContext()) { return(db.Voting.FirstOrDefault(v => v.UserId == voting.UserId && v.IdeaId == voting.IdeaId) != null); } }
public IEnumerable <News> GetAllNews() { using (var db = new ActiveCitizenContext()) { return(db.News.ToList()); } }
public Users GetUserBySnils(long snils) { using (var db = new ActiveCitizenContext()) { return(db.Users.Where(u => u.Snils == snils).FirstOrDefault()); } }
public IdeaComment GetCommentById(int id) { using (var db = new ActiveCitizenContext()) { return(db.IdeaComment.Find(id)); } }
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()); } }
public void AddProject(Project project) { using (var db = new ActiveCitizenContext()) { db.Project.Add(project); db.SaveChanges(); } }
public bool UpdateDirection(ProjectDirection direction) { using (var db = new ActiveCitizenContext()) { db.Entry(db.ProjectDirection.Find(direction.Id)).CurrentValues.SetValues(direction); return(db.SaveChanges() > 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); } }
public bool RealiseIdea(int id) { using (var db = new ActiveCitizenContext()) { db.DirectionIdea.Find(id).IsRealised = true; return(db.SaveChanges() > 0); } }
public bool UpdateUserRole(int userId, int role) { using (var db = new ActiveCitizenContext()) { db.Users.Find(userId).Role = role; return(db.SaveChanges() > 0); } }
public bool ConfirmUserEmail(int id) { using (var db = new ActiveCitizenContext()) { db.Users.Find(id).IsConfirmedEmail = true; return(db.SaveChanges() > 0); } }
public void AddUser(Users user) { using (var db = new ActiveCitizenContext()) { db.Users.Add(user); db.SaveChanges(); } }
public Users GetUserByEmail(string email) { using (var db = new ActiveCitizenContext()) { var user = db.Users.Where(u => u.Email == email).Include("DistrictNavigation").FirstOrDefault(); return(user); } }
public bool DeleteProject(int id) { using (var db = new ActiveCitizenContext()) { db.Project.Remove(db.Project.Find(id)); return(db.SaveChanges() > 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); } }
public bool UpdateUserAvatar(int userId, string avatar) { using (var db = new ActiveCitizenContext()) { db.Users.Find(userId).UserAvatar = avatar; return(db.SaveChanges() > 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); } }
public bool UpdateProject(Project project) { using (var db = new ActiveCitizenContext()) { db.Entry(db.Project.Find(project.Id)).CurrentValues.SetValues(project); return(db.SaveChanges() > 0); } }
public bool DeleteUserAvatar(int userId) { using (var db = new ActiveCitizenContext()) { db.Users.Find(userId).UserAvatar = null; return(db.SaveChanges() > 0); } }
public bool DeleteDirection(ProjectDirection direction) { using (var db = new ActiveCitizenContext()) { db.Remove(db.ProjectDirection.Find(direction.Id)); return(db.SaveChanges() > 0); } }
public bool AddDirection(ProjectDirection direction) { using (var db = new ActiveCitizenContext()) { db.ProjectDirection.Add(direction); return(db.SaveChanges() > 0); } }
public bool AddNews(News news) { using (var db = new ActiveCitizenContext()) { db.News.Add(news); return(db.SaveChanges() > 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); } }