public IActionResult ProjectSystem() { ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); if (ViewBag.IsLogin) { ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user")); } else { return(RedirectToAction("Login", "Account")); } if (!ViewBag.User.IsAdmin) { return(RedirectToAction("Login", "Account")); } ViewBag.GuestRankId = serviceConfig.GuestRankId; ViewBag.MasterRankId = serviceConfig.MasterRankId; ViewBag.NewStatusId = serviceConfig.StatusNewId; var model = new ProjectSystemViewModel { ranks = ranksvc.GetAllRank(), status = statussvc.GetAllStatus() }; return(View(model)); }
public IActionResult Index(string projectid) { ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); if (ViewBag.IsLogin) { ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user")); } else { return(RedirectToAction("Login", "Account")); } var project = projectSvc.GetProject(projectid); var allAcc = accountSvc.GetAllAccount(); var memberships = membershipSvc.GetAllProjectMember(projectid); var features = featureSvc.GetFeatures(projectid); var ranks = rankSvc.GetAllRank(); var displayMemberships = new List <DisplayMembership>(); foreach (var item in allAcc) { var membership = memberships.FirstOrDefault(it => it.Account_id == item._id); var rankName = string.Empty; if (membership != null) { var rank = ranks.FirstOrDefault(it => it._id == membership.ProjectRank_id); rankName = rank != null ? rank.RankName : string.Empty; var model = new DisplayMembership(membership) { AccountName = $"{item.FirstName} {item.LastName}", Email = item.Email, RankName = rankName }; displayMemberships.Add(model); } } var displayFeatures = GetCurrentUserManagementFeatures(project._id); return(View(new ProjectDetailModel { Project = project, Memberships = displayMemberships, Features = displayFeatures })); }
public IActionResult EditFeature(FeatureModel model) { ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); if (ViewBag.IsLogin) { ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user")); } else { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { var project = projectSvc.GetProject(model.Project_id); var isValid = ValidateClosingDate(false, project, model); if (!isValid) { PrepareDataForDisplay(model.Project_id, model); return(View(model)); } if (!string.IsNullOrEmpty(model.BeAssignedMember_id)) { var memberships = membershipSvc.GetAllProjectMember(model.Project_id); var ranks = rankSvc.GetAllRank(); var member = ViewBag.User != null?memberships.FirstOrDefault(it => it.Account_id == ViewBag.User._id && !it.RemoveDate.HasValue) : null; var userRank = (ranks.FirstOrDefault(it => it._id == member.ProjectRank_id)); var canAssign = userRank.CanAssign || member.CanAssign; if (canAssign) { model.AssginByMember_id = ViewBag.User._id; } } else { model.AssginByMember_id = string.Empty; } model.ClosingDate = model.ClosingDate.AddDays(1); featureSvc.EditFeature(model); return(RedirectToAction(nameof(FeatureDetail), new { projectid = model.Project_id, featureid = model._id })); } PrepareDataForDisplay(model.Project_id, model); return(View(model)); }
public IActionResult Index() { ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); if (ViewBag.IsLogin) { ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user")); } else { return(RedirectToAction("Login", "Account")); } ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); var allAcc = accountSvc.GetAllAccount(); var model = projectSvc.GetProjects(ViewBag.User._id); var ranks = rankSvc.GetAllRank(); var GraphData = new List <ProjectGraphModel>() { }; foreach (var project in model) { List <ProjectMembershipModel> memberships = membershipSvc.GetAllProjectMember(project._id); var members = memberships.Where(it => it.Account_id == ViewBag.User._id && !it.RemoveDate.HasValue); var data = new ProjectGraphModel() { ProjectId = project._id, ProjectName = project.ProjectName }; List <FeatureModel> features = featureSvc.GetFeatures(project._id); var member = members.FirstOrDefault(it => it.Project_id == project._id); var CanSeeAllWork = member != null ? (ranks.FirstOrDefault(it => it._id == member.ProjectRank_id).CanSeeAllWork) || member.CanSeeAllWork : false; //if (true) //{ // data.WorkDone = features.Where(it => it.WorkDoneDate.HasValue).Count() + features.Sum(it => storySvc.GetStories(it._id).Where(st => st.WorkDoneDate.HasValue).Count()) + features.Sum(it => storySvc.GetStories(it._id).Sum(st => taskSvc.GetTasks(st._id).Where(t => t.WorkDoneDate.HasValue).Count())); // data.WorkProcess = features.Where(it => !it.WorkDoneDate.HasValue).Count() + features.Sum(it => storySvc.GetStories(it._id).Where(st => !st.WorkDoneDate.HasValue).Count()) + features.Sum(it => storySvc.GetStories(it._id).Sum(st => taskSvc.GetTasks(st._id).Where(t => !t.WorkDoneDate.HasValue).Count())); // GraphData.Add(data); //} //else //{ var Features = new List <DisplayFeatureModel>(); var displayFeatures = new List <DisplayFeatureModel>(); foreach (var feature in features) { var MyFeatureWork = false; MyFeatureWork = member != null ? (feature.BeAssignedMember_id == member.Account_id || CanSeeAllWork) : false; var feature_CreateByAccount = allAcc.FirstOrDefault(it => it._id == feature.CreateByMember_id); var feature_AssginByAccount = allAcc.FirstOrDefault(it => it._id == feature.AssginByMember_id); var feature_BeassginByAccount = allAcc.FirstOrDefault(it => it._id == feature.BeAssignedMember_id); var Stories = new List <DisplayStoryModel>(); var displayStories = new List <DisplayStoryModel>(); var stories = storySvc.GetStories(feature._id); foreach (var story in stories) { var MyStoryWork = false; MyStoryWork = member != null ? (story.BeAssignedMember_id == member.Account_id || CanSeeAllWork) : false; var story_AssginByAccount = allAcc.FirstOrDefault(it => it._id == story.AssginByMember_id); var story_BeassginByAccount = allAcc.FirstOrDefault(it => it._id == story.BeAssignedMember_id); var story_CreateByAccount = allAcc.FirstOrDefault(it => it._id == story.CreateByMember_id); var Tasks = new List <DisplayTaskModel>(); var displayTasks = new List <DisplayTaskModel>(); var tasks = taskSvc.GetTasks(story._id); foreach (var task in tasks) { var MyTaskWork = false; MyTaskWork = member != null ? (task.BeAssignedMember_id == member.Account_id || CanSeeAllWork) : false; var task_AssginByAccount = allAcc.FirstOrDefault(it => it._id == task.AssginByMember_id); var task_BeassginByAccount = allAcc.FirstOrDefault(it => it._id == task.BeAssignedMember_id); var task_CreateByAccount = allAcc.FirstOrDefault(it => it._id == task.CreateByMember_id); var model_task = new DisplayTaskModel(task) { CreateByMemberName = task_CreateByAccount != null ? $"{task_CreateByAccount.FirstName} {task_CreateByAccount.LastName}" : "-", AssginByMemberName = task_AssginByAccount != null ? $"{task_AssginByAccount.FirstName} {task_AssginByAccount.LastName}" : "-", BeAssignedMemberName = task_BeassginByAccount != null ? $"{task_BeassginByAccount.FirstName} {task_BeassginByAccount.LastName}" : "-", }; Tasks.Add(model_task); if (MyTaskWork || MyStoryWork || MyFeatureWork) { displayTasks.Add(model_task); } } var model_storyAllTask = new DisplayStoryModel(story) { CreateByMemberName = story_CreateByAccount != null ? $"{story_CreateByAccount.FirstName} {story_CreateByAccount.LastName}" : "-", AssginByMemberName = story_AssginByAccount != null ? $"{story_AssginByAccount.FirstName} {story_AssginByAccount.LastName}" : "-", BeAssignedMemberName = story_BeassginByAccount != null ? $"{story_BeassginByAccount.FirstName} {story_BeassginByAccount.LastName}" : "-", Tasks = Tasks }; var model_story = new DisplayStoryModel(story) { CreateByMemberName = story_CreateByAccount != null ? $"{story_CreateByAccount.FirstName} {story_CreateByAccount.LastName}" : "-", AssginByMemberName = story_AssginByAccount != null ? $"{story_AssginByAccount.FirstName} {story_AssginByAccount.LastName}" : "-", BeAssignedMemberName = story_BeassginByAccount != null ? $"{story_BeassginByAccount.FirstName} {story_BeassginByAccount.LastName}" : "-", Tasks = displayTasks }; Stories.Add(model_storyAllTask); if (MyStoryWork || model_story.Tasks.Count() > 0 || MyFeatureWork) { displayStories.Add(model_story); } } var model_featureAllStory = new DisplayFeatureModel(feature) { CreateByMemberName = feature_CreateByAccount != null ? $"{feature_CreateByAccount.FirstName} {feature_CreateByAccount.LastName}" : "-", AssginByMemberName = feature_AssginByAccount != null ? $"{feature_AssginByAccount.FirstName} {feature_AssginByAccount.LastName}" : "-", BeAssignedMemberName = feature_BeassginByAccount != null ? $"{feature_BeassginByAccount.FirstName} {feature_BeassginByAccount.LastName}" : "-", Stories = Stories }; var model_feature = new DisplayFeatureModel(feature) { CreateByMemberName = feature_CreateByAccount != null ? $"{feature_CreateByAccount.FirstName} {feature_CreateByAccount.LastName}" : "-", AssginByMemberName = feature_AssginByAccount != null ? $"{feature_AssginByAccount.FirstName} {feature_AssginByAccount.LastName}" : "-", BeAssignedMemberName = feature_BeassginByAccount != null ? $"{feature_BeassginByAccount.FirstName} {feature_BeassginByAccount.LastName}" : "-", Stories = displayStories }; Features.Add(model_featureAllStory); if (MyFeatureWork || model_feature.Stories.Count() > 0) { displayFeatures.Add(model_feature); } } if (CanSeeAllWork) { data.WorkDone = Features.Where(it => it.WorkDoneDate.HasValue).Count() + Features.Sum(it => it.Stories.Where(st => st.WorkDoneDate.HasValue).Count()) + Features.Sum(it => it.Stories.Sum(st => st.Tasks.Where(t => t.WorkDoneDate.HasValue).Count())); data.WorkProcess = Features.Where(it => !it.WorkDoneDate.HasValue).Count() + Features.Sum(it => it.Stories.Where(st => !st.WorkDoneDate.HasValue).Count()) + Features.Sum(it => it.Stories.Sum(st => st.Tasks.Where(t => !t.WorkDoneDate.HasValue).Count())); } else { data.WorkDone = displayFeatures.Where(it => it.WorkDoneDate.HasValue).Count() + displayFeatures.Sum(it => it.Stories.Where(st => st.WorkDoneDate.HasValue).Count()) + displayFeatures.Sum(it => it.Stories.Sum(st => st.Tasks.Where(t => t.WorkDoneDate.HasValue).Count())); data.WorkProcess = displayFeatures.Where(it => !it.WorkDoneDate.HasValue).Count() + displayFeatures.Sum(it => it.Stories.Where(st => !st.WorkDoneDate.HasValue).Count()) + displayFeatures.Sum(it => it.Stories.Sum(st => st.Tasks.Where(t => !t.WorkDoneDate.HasValue).Count())); } GraphData.Add(data); //} } ViewBag.CanCreateProject = ViewBag.User.ProjectCreatable; ViewBag.Data = GraphData; return(View(model)); }