public Bug Update(Bug bug) { bug.LastModified = DateTime.Now; using (var ctx = new WcfEntityContext()) { var oldBug = ctx.Bugs.Include("CreatedBy").Include("Project").Include("AssignedUser") .Where(h => h.Id == bug.Id).SingleOrDefault(); var userCreated = ctx.Users.Where(n => n.Id == bug.CreatedBy.Id).SingleOrDefault(); var assignedProject = ctx.Projects.Where(c => c.Id == bug.Project.Id).SingleOrDefault(); if (bug.AssignedUser != null) { var userAssigned = ctx.Users.Where(u => u.Id == bug.AssignedUser.Id).SingleOrDefault(); oldBug.AssignedUser = userAssigned; } oldBug.CreatedBy = userCreated; oldBug.Project = assignedProject; ctx.Bugs.ApplyCurrentValues(bug); ctx.SaveChanges(); return bug; } }
/*[PrincipalPermission(SecurityAction.Demand, Role = "ADMIN")]*/ public void DeleteBug(Bug bug) { BugRepository repo = new BugRepository(); repo.Delete(bug); BugActionLogger.LogEvent(bug.Project, GetMyUser(), BugActionLogger.Delete_Action, bug); }
public Bug Create(Bug bug) { bug.DateFound = DateTime.Now; bug.LastModified = DateTime.Now; using (var ctx = new WcfEntityContext()) { var project = ctx.Projects.Where(x => x.Id == bug.Project.Id) .SingleOrDefault(); var createdBy = ctx.Users.Where (u => u.Id == bug.CreatedBy.Id) .SingleOrDefault(); if (bug.AssignedUser != null) { var assignedUser = ctx.Users.Where(p => p.Id == bug.AssignedUser.Id).SingleOrDefault(); bug.AssignedUser = assignedUser; } bug.CreatedBy = createdBy; bug.Project = project; ctx.Bugs.AddObject(bug); ctx.SaveChanges(); return bug; } }
public static void LogEvent(Project project, User user, int actionConst, Bug bug) { var action = new BugActionRepository().GetAll().Where(p => p.Id == actionConst).SingleOrDefault(); var proj = new ProjectRepository().GetAll().Where(p => p.Id == project.Id).SingleOrDefault(); new BugActionLogRepository().Create(new BugActionLog { Project = proj, Action = action, BugName = bug.Name, UserName = user.FirstName.Substring(0, 1) + "." + user.Surname }); }
public Bug AddBug(Bug bug) { bug.DateFound = DateTime.Now; bug.LastModified = DateTime.Now; var savedbug = new BugRepository().Create(bug); BugActionLogger.LogEvent(bug.Project, GetMyUser(), BugActionLogger.Create_Action, savedbug); return savedbug; }
public void Delete(Bug bug) { using (var ctx = new WcfEntityContext()) { Bug mybug = ctx.Bugs.Where(p => p.Id == bug.Id).FirstOrDefault(); ctx.Bugs.Attach(mybug); ctx.Bugs.DeleteObject(mybug); ctx.SaveChanges(); } }
public Bug SaveBug(Bug bug) { bug.LastModified = DateTime.Now; BugRepository bugRepo = new BugRepository(); var savedbug = bugRepo.Update(bug); BugActionLogger.LogEvent(bug.Project, GetMyUser(), BugActionLogger.Update_Action, savedbug); return bug; }