private static void CreateTestProject(PROGRESSTRACKERContext context) { Ptproject project = new Ptproject { Name = "Test Project", Description = "This is a test project", Ptuser = context.Ptuser.First(), Status = ProjectStatus.None.ToString(), Active = true }; context.Ptproject.Add(project); context.SaveChanges(); Pttask task = new Pttask { Description = "First Task", PtprojectId = project.Id, Completed = false, Active = true }; context.Pttask.Add(task); context.SaveChanges(); }
public TopNavbarViewModel(string title, bool isAuthenticated = false, string returnUrl = null, string addUrl = null, string editUrl = null, string deleteUrl = null, Ptproject project = null) { Title = title; ReturnUrl = returnUrl; AddUrl = addUrl; EditUrl = editUrl; DeleteUrl = deleteUrl; IsAuthenticated = isAuthenticated; Project = project; }
private void SetProgress(Ptproject project) { decimal progress = -1; try { int total = project.Pttask.Count; int completed = project.Pttask.Count(o => o.Completed); progress = total != 0 ? (decimal)completed / total : 0; Progress = progress >= 0 && progress <= 1 ? progress : Progress; if (total == 0) { Progress = 0; } UnresolvedCount = total - completed; } catch (Exception ex) { throw ex; } }
public ProjectViewModel(Ptproject project) { Project = project; SetProgress(project); SetStatus(); }