public IViewComponentResult Invoke() { IEnumerable <UserIdentity> users = userRepo.GetAllUsers(); //.OrderBy(o => o.ClientCreated == false; //VMUsersClients list = new VMUsersClients(); foreach (UserIdentity u in users) { if (clientRepo.ContainsClient(u.Email)) { u.ClientCreated = true; } } return(View(users.OrderBy(u => u.ClientCreated == true))); }
public IActionResult CreateProject(VMCreateProject projectVM) { //if model requirements fulfilled if (ModelState.IsValid) { //finds user in Clients based on Email from user Client client = clientRepo.GetClientByEmail(projectVM.Email); if (clientRepo.ContainsClient(client) == true) //(client != null) { //if client is entered and found //searches for open bid for given client Bid bid = bidrepo.GetBidByID(projectVM.BidID); if (bid != null) { //create project Project project = new Project { ProjectID = projectVM.ProjectID, Client = clientRepo.GetClientById(projectVM.ClientID), ProjectName = projectVM.ProjectName, StartDate = projectVM.StartDate, OriginalEstimate = projectVM.Estimate, Bid = bidrepo.GetBidByID(projectVM.BidID), ProjectStatus = "Started", StatusDate = DateTime.Today }; project.TotalCost = project.OriginalEstimate; //if client and bid are valid if (project.Client != null && project.Bid != null) { //add project to database projectRepo.ProjectUpdate(project); } else { ModelState.AddModelError("Email", "Either the attributed Client or Bid is invalid"); } return(RedirectToAction("AdminPage", "Admin")); } else { //if bid not found ModelState.AddModelError("Email", "Could not find open bid for client tied to that email"); } } else { //if user not found ModelState.AddModelError("LastName", "There is no client found in the system with that e-mail"); } } else { //if model not valid ModelState.AddModelError("Email", "Please make sure all fields are filled"); } return(View(projectVM)); }