private Project ConvertToDomain(ProjectsDao dao) { return(new Project() { Id = dao.ProjectId, CurrentPhase = new Phase() { Id = dao.CurrentPhaseId }, User = new UimvcUser() { Id = dao.UserId }, Platform = new Platform() { Id = dao.PlatformId }, Title = dao.Title, Goal = dao.Goal, Status = dao.Status, Visible = dao.Visible, LikeVisibility = dao.LikeVisibility, ReactionCount = dao.ReactionCount, LikeCount = dao.LikeCount, FbLikeCount = dao.FbLikeCount, TwitterLikeCount = dao.TwitterLikeCount }); }
public void Delete(int id) { ProjectsDao toDelete = _ctx.Projects.First(p => p.ProjectId == id); _ctx.Projects.Remove(toDelete); _ctx.SaveChanges(); }
public Project Read(int id, bool details) { ProjectsDao projectsDao = details ? _ctx.Projects.AsNoTracking().FirstOrDefault(p => p.ProjectId == id) : _ctx.Projects.FirstOrDefault(p => p.ProjectId == id); ExtensionMethods.CheckForNotFound(projectsDao, "Project", id); return(ConvertToDomain(projectsDao)); }
public void Update(Project obj) { ProjectsDao newProj = ConvertToDao(obj); ProjectsDao foundProj = _ctx.Projects.First(p => p.ProjectId == obj.Id); if (foundProj != null) { foundProj.Title = newProj.Title; foundProj.Goal = newProj.Goal; foundProj.CurrentPhaseId = newProj.CurrentPhaseId; foundProj.Status = newProj.Status; foundProj.Visible = newProj.Visible; foundProj.ReactionCount = newProj.ReactionCount; foundProj.LikeCount = newProj.LikeCount; foundProj.FbLikeCount = newProj.FbLikeCount; foundProj.TwitterLikeCount = newProj.TwitterLikeCount; foundProj.LikeVisibility = newProj.LikeVisibility; } _ctx.SaveChanges(); }