protected override void Seed(MUMScrumDbContext context) { context.Roles.Add(new Model.Role() { RoleName = "HR" }); context.Roles.Add(new Model.Role() { RoleName = "ScrumMaster" }); context.Roles.Add(new Model.Role() { RoleName = "ProductOwner" }); context.Roles.Add(new Model.Role() { RoleName = "Developer" }); context.Roles.Add(new Model.Role() { RoleName = "Tester" }); context.SaveChanges(); context.Employees.Add(new Model.Employee { FirstName = "Super", LastName = "Admin", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.HR }); var po = new Model.Employee { FirstName = "John", LastName = "Doe", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.ProductOwner, }; context.Employees.Add(po); var po1 = new Model.Employee { FirstName = "Rabin", LastName = "Doe", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.ProductOwner, }; context.Employees.Add(po1); context.SaveChanges(); context.Employees.Add(new Model.Employee { FirstName = "Grace", LastName = "Monroe", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.Developer, }); context.Employees.Add(new Model.Employee { FirstName = "David", LastName = "Fake", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.Tester, }); context.Employees.Add(new Model.Employee { FirstName = "Jane", LastName = "Roe", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.ScrumMaster, }); context.Employees.Add(new Model.Employee { FirstName = "Sanjeev", LastName = "Rajbanshi", UserName = "******", Password = "******", IsDeactivated = false, RoleId = (int)RoleEnum.ScrumMaster, }); context.SaveChanges(); for (int i = 1; i <= 1; i++) { var newProduct = new Model.ProductBacklog() { Name = "MUMScrum ", Description = "Our MUMScrum - " + i + " Backlog", OwnerId = po.Id }; context.ProductBacklogs.Add(newProduct); } context.SaveChanges(); for (int i = 1; i <= 1; i++) { //var skip = (i - 1) % 5; var product = context.ProductBacklogs.FirstOrDefault(); var newRelease = new ReleaseBacklog() { ReleaseDate = DateTime.Now.Date.AddDays(20), Description = "this release is for the final project presentation of Software Engineering block. Hope it goes all well", ReleaseName = "Release V" + i }; //newRelease.ReleaseDate = DateTime.Now; newRelease.ProductBacklogId = product.Id; newRelease.ScrumMasterId = 6; context.ReleaseBacklogs.Add(newRelease); } context.SaveChanges(); for (int i = 1; i <= 2; i++) { var release = context.ReleaseBacklogs.FirstOrDefault(); var sprint = new Sprint(); sprint.ReleaseBacklogId = release.Id; sprint.Description = "This is new Sprint for this release - " + release.ReleaseName; sprint.SprintRunning = false; if (i == 1) { sprint.StartDate = DateTime.Now.AddDays(-5); sprint.EndDate = DateTime.Now; } else { sprint.StartDate = DateTime.Now; sprint.EndDate = DateTime.Now.Date.AddDays(5); } sprint.SprintName = "Sprint - " + i; context.Sprints.Add(sprint); } context.SaveChanges(); for (int i = 1; i <= 3; i++) { var product = context.ProductBacklogs.FirstOrDefault(); //var pcount = (i - 1) % product.ReleaseBacklogs.Count(); var release = product.ReleaseBacklogs.OrderBy(j => j.Id).FirstOrDefault(); //var rcount = (i - 1) % context.Sprints.Where(j => j.ReleaseBacklogId == release.Id).Count(); var sprint = context.Sprints.Where(j => j.ReleaseBacklogId == release.Id).OrderBy(j => j.Id).FirstOrDefault(); var US = new UserStory() { Title = "UStory - " + i, Description = "This is a " + i + " description", SprintId = sprint.Id, ReleaseId = release.Id, DevelopedId = context.Employees.First(d => d.RoleId == (int)RoleEnum.Developer).Id, TesterId = context.Employees.First(d => d.RoleId == (int)RoleEnum.Tester).Id, ProductBackLogId = product.Id, DevActual = 0, TestActual = 0, DevEstimate = 30, TestEstiamte = 0 }; context.UserStories.Add(US); } context.SaveChanges(); var sprint1 = context.Sprints.FirstOrDefault(); foreach (var us in sprint1.UserStories.ToList()) { var currentdevActual = us.DevActual.Value; var currentdevEstimate = us.DevEstimate.Value; for (int i = 1; i < 5; i++) { var usLog = new UserStoryLog() { ChangedByUserId = us.DevelopedId.Value, Date = sprint1.StartDate.AddDays(i), LogType = LogType.DevActual, NewValue = 5, OldValue = currentdevActual, UserStoryId = us.Id }; us.DevActual += 5; context.UserStoryLogs.Add(usLog); } } context.SaveChanges(); }
public bool UpdateUserStory(UserStory US, int Id) { UserStory DbUs = GetUserStoryById(US.Id); // each user will update just the needed information that he's interested in it! if (Id == (int)RoleEnum.ProductOwner) { DbUs.Title = US.Title; DbUs.Description = US.Description; DbUs.ProductBackLogId = US.ProductBackLogId; DbUs.ReleaseId = US.ReleaseId; DbUs.SprintId = US.SprintId; } else if (Id == (int)RoleEnum.ScrumMaster) { DbUs.SprintId = US.SprintId; DbUs.DevelopedId = US.DevelopedId; DbUs.TesterId = US.TesterId; } else if (Id == (int)RoleEnum.Developer) { if (DbUs.DevActual != US.DevActual) { UserStoryLog USLog = new UserStoryLog(); USLog.ChangedByUserId = Id; USLog.LogType = LogType.DevActual; USLog.UserStoryId = DbUs.Id; USLog.NewValue = (US.DevActual.HasValue ? US.DevActual.Value : 0) - (DbUs.DevActual.HasValue ? DbUs.DevActual.Value : 0); USLog.OldValue = DbUs.DevActual.HasValue ? DbUs.DevActual.Value : 0; USLog.Date = DateTime.Now; UnitOfWork.UserStoryLogRepository.Insert(USLog); } DbUs.DevEstimate = US.DevEstimate; DbUs.DevActual = US.DevActual; } else if (Id == (int)RoleEnum.Tester) { if (DbUs.TestActual != US.TestActual) { UserStoryLog USLog = new UserStoryLog(); USLog.ChangedByUserId = Id; USLog.LogType = LogType.TestActual; USLog.UserStoryId = DbUs.Id; USLog.NewValue = (US.TestActual.HasValue ? US.TestActual.Value : 0) - (DbUs.TestActual.HasValue ? DbUs.TestActual.Value : 0); USLog.OldValue = DbUs.TestActual.HasValue ? DbUs.TestActual.Value : 0; USLog.Date = DateTime.Now; UnitOfWork.UserStoryLogRepository.Insert(USLog); } DbUs.TestEstiamte = US.TestEstiamte; DbUs.TestActual = US.TestActual; } UnitOfWork.UserStoryRepository.Update(DbUs); return(UnitOfWork.SaveChanges()); }