public async Task <IActionResult> Create([Bind("ID,ProjectID,TeamID")] ProductionPlan productionPlan, string[] selectedProdLabors, string[] selectedProdMaterials) { try { UpdateProdLabors(selectedProdLabors, productionPlan); UpdateProdMaterials(selectedProdMaterials, productionPlan); if (ModelState.IsValid) { _context.Add(productionPlan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator."); } PopulateAssignedLaborData(productionPlan); PopulateAssignedMaterialData(productionPlan); ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Name", productionPlan.ProjectID); ViewData["TeamID"] = new SelectList(_context.Teams, "ID", "Phase", productionPlan.TeamID); return(View(productionPlan)); }
//[Authorize(Roles = "Admin,Manager")] public async Task <IActionResult> Create([Bind("ID,Phase,TeamName")] Team team, string[] selectedOptions) { try { UpdateEmpFullNametoTeam(selectedOptions, team); if (ModelState.IsValid) { _context.Add(team); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "FullName", team.EmployeeID); //ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Name", team.ProjectID); } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator."); } //catch (DbUpdateException) //{ // ModelState.AddModelError("", "Something went wrong in the database."); //} PopulateAssignedEmpData(team); return(View(team)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Desc,EstCost,BidDate,EstStartDate,EstFinishDate,StartDate,FinishDate,Cost,BidCustApproved,BidManagementApproved,ClientID,DesignerID")] Project project) { if (id != project.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(project); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(project.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } PopulateDropDownLists(project); return(View(project)); }
public async Task <IActionResult> Create([Bind("ID,Name,Desc,EstCost,BidDate,EstStartDate,EstFinishDate,Cost,BidCustApproved,BidManagementApproved,ClientID,DesignerID")] Project project, string[] selectedLabOptions, string[] selectedLabQuantity, string[] selectedMatOptions, string[] selectedMatQuantity) { try { int ctr = 0; int a = 0; //Add the selected conditions if (selectedLabOptions != null) { project.LabourSummaries = new List <LabourSummary>(); foreach (var employeeType in selectedLabOptions) { var employeeTypeToAdd = new LabourSummary { ProjectID = project.ID, EmployeeTypeID = int.Parse(employeeType), Hours = int.Parse(selectedLabQuantity[ctr]) }; project.LabourSummaries.Add(employeeTypeToAdd); ctr++; } } if (selectedMatOptions != null) { project.ProjectMaterials = new List <ProjectMaterials>(); foreach (var inventory in selectedMatOptions) { var inventoryToAdd = new ProjectMaterials { ProjectID = project.ID, InventoryID = int.Parse(inventory), MatEstQty = int.Parse(selectedMatQuantity[a]) }; project.ProjectMaterials.Add(inventoryToAdd); a++; } } if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator."); } catch (Exception) { ModelState.AddModelError("", "Unknown error!"); } PopulateAssignedEmployeeTypes(project); PopulateAssignedMaterials(project); PopulateDropDownLists(project); return(View(project)); }
public async Task <IActionResult> Create([Bind("ID,Name")] Stage stage) { if (ModelState.IsValid) { _context.Add(stage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(stage)); }
public async Task <IActionResult> Create([Bind("ID,Submitter,SubmissionDate,ProjectID")] ProductionWorkReport productionWorkReport) { if (ModelState.IsValid) { _context.Add(productionWorkReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", productionWorkReport.ProjectID); return(View(productionWorkReport)); }
public async Task <IActionResult> Create([Bind("ID,CurrentHours,EstHours,HoursTotal,SubmissionDate,Submitter,ProjectID")] DesignBudget designBudget) { if (ModelState.IsValid) { _context.Add(designBudget); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", designBudget.ProjectID); return(View(designBudget)); }
public async Task <IActionResult> Create([Bind("ID,Stage,Hours,Task,Submitter,SubmissionDate,ProjectID")] DesignDay designDay) { if (ModelState.IsValid) { _context.Add(designDay); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", designDay.ProjectID); return(View(designDay)); }
public async Task <IActionResult> Create([Bind("ID,Name,Phone,Address,Province,Postal,ConFirst,ConLast,ConPhone,ConPosition,CityID")] Client client) { if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CityID"] = new SelectList(_context.Cities, "ID", "Name"); return(View(client)); }
public async Task <IActionResult> Create([Bind("Id,Bid,EstProdPlan,TotalCosttoDate,ActualMtl,EstimatedDesingCost,ActuLaborPro,EstLaborProdCost,ActuLaborDesingCost,EstLaborDesingCost,ProjectID")] ProductionStageReport productionStageReport) { if (ModelState.IsValid) { _context.Add(productionStageReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Name", productionStageReport.ProjectID); return(View(productionStageReport)); }
public async Task <IActionResult> Create([Bind("ID,EstBid,ActlHours,EstHours,ActlCosts,EstCost,HoursRemaining,CostsRemaining,ProjectID")] BidReport bidReport) { if (ModelState.IsValid) { _context.Add(bidReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", bidReport.ProjectID); return(View(bidReport)); }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,CompanyName,Position,PhoneNumber,Address,CityID,Province,PostalCode,Email")] Client client) { if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CityID"] = new SelectList(_context.Cities, "ID", "ID", client.CityID); return(View(client)); }
public async Task <IActionResult> Create([Bind("ID,AvgNetPrice,ListPrice,SizeValue,SizeUnit,Quantity,MaterialID")] Inventory inventory) { if (ModelState.IsValid) { _context.Add(inventory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaterialID"] = new SelectList(_context.Materials, "ID", "ID", inventory.MaterialID); return(View(inventory)); }
public async Task <IActionResult> Create([Bind("ID,BidID,EstStart,EstEnd,Amount,Location,ProjectID")] Bid bid) { if (ModelState.IsValid) { _context.Add(bid); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", bid.ProjectID); return(View(bid)); }
public async Task <IActionResult> Create([Bind("ID,BidCost,EstCost,TotalCost,ActualMtlCost,EstMtlCost,ActualLabourProdCost,EstLabourProdCost,ActualDesignCost,EstDesignCost,ProjectID")] ProductionReport productionReport) { if (ModelState.IsValid) { _context.Add(productionReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", productionReport.ProjectID); return(View(productionReport)); }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,Email,PhoneNumber,DepartmentID")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentID"] = new SelectList(_context.Departments, "ID", "Description", employee.DepartmentID); return(View(employee)); }
public async Task <IActionResult> Create([Bind("ProjectID,InventoryID,MatDelivery,MatInstall,MatEstQty,MatActQty")] ProjectMaterials projectMaterials) { if (ModelState.IsValid) { _context.Add(projectMaterials); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["InventoryID"] = new SelectList(_context.Inventories, "ID", "ID", projectMaterials.InventoryID); ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Desc", projectMaterials.ProjectID); return(View(projectMaterials)); }
public async Task <IActionResult> Add([Bind("ID,EstStartDate,EstHours,TeamID,TaskID")] Labour labour) { if (ModelState.IsValid) { _context.Add(labour); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //PopulateDDl(labour); return(View(labour)); }
public async Task <IActionResult> Create([Bind("ID,Quantity,Costs,Date,EmployeeID,ProjectID,MaterialID")] MaterialReport materialReport) { if (ModelState.IsValid) { _context.Add(materialReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "FullName", materialReport.EmployeeID); ViewData["MaterialID"] = new SelectList(_context.Materials, "ID", "Description", materialReport.MaterialID); ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Name", materialReport.ProjectID); return(View(materialReport)); }
public async Task <IActionResult> Create([Bind("ID,Hours,Costs,Date,EmployeeID,ProjectID,TaskID")] WorkerReport workerReport) { if (ModelState.IsValid) { _context.Add(workerReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "FullName", workerReport.EmployeeID); ViewData["ProjectID"] = new SelectList(_context.Projects, "ID", "Name", workerReport.ProjectID); ViewData["TaskID"] = new SelectList(_context.Tasks, "ID", "Description", workerReport.TaskID); return(View(workerReport)); }
public async Task <IActionResult> Add([Bind("ID,ProjectID,EmployeeID")] ProjectEmployee projectEmployee) { try { if (ModelState.IsValid) { _context.Add(projectEmployee); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { projectEmployee.ProjectID })); } } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } PopulateDropdownLists(projectEmployee.ProjectID); return(View(projectEmployee)); }
public async Task <IActionResult> Create([Bind("ID,Name,ProjSite,ProjBidDate,EstStartDate,EstEndDate,StartDate,EndDate,ActAmount,EstAmount,ClientApproval,AdminApproval,ProjCurrentPhase,ClientID,ProjIsFlagged")] Project project, string [] selectedLabors, string[] selectedMaterials) { try { UpdateProjectLabours(selectedLabors, project); UpdateProjectMaterials(selectedMaterials, project); if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator."); } PopulateAssignedLaborData(project); PopulateAssignedMaterialData(project); ViewData["ClientID"] = new SelectList(_context.Clients, "ID", "FullName", project.ClientID); return(View(project)); }
public async Task <IActionResult> Create([Bind("ID,Name,Desc,EstCost,BidDate,EstStartDate,EstFinishDate,CurrentPhase,StartDate,FinishDate,Cost,BidCustApproved,BidManagementApproved,ClientID,DesignerID")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClientID"] = new SelectList(_context.Clients, "ID", "ConFirst", project.ClientID); ViewData["DesignerID"] = new SelectList(_context.Employees, "ID", "FirstName", project.DesignerID); return(View(project)); }