public ActionResult CreateBillingCorrection(ProjectBillingViewModel projectBillingCorrection) { if (ModelState.IsValid) { if (!DoIHaveAccessToProject(projectBillingCorrection.ProjectId)) { return(RedirectToAction("NotAuthorized", "Error", new { area = "" })); } var newBilling = new ProjectBillingCorrection { ProjectId = projectBillingCorrection.ProjectId, BillingHours = projectBillingCorrection.BillingHours, Comments = projectBillingCorrection.Comments }; newBilling.CreatedByUserId = WebUser.Id; _projectBillingCorrectionRepository.Create(newBilling); _unitOfWork.Commit(); return(RedirectToAction("Details", "Projects", new { Id = projectBillingCorrection.ProjectId })); } ViewBag.ProjectId = new SelectList(_projectRepository.GetAll(), "Id", "Title", projectBillingCorrection.ProjectId); return(View(projectBillingCorrection)); }
public ActionResult CreateBillingCorrection(int projectId) { if (!DoIHaveAccessToProject(projectId)) { return(RedirectToAction("NotAuthorized", "Error", new { area = "" })); } var vm = new ProjectBillingViewModel { ProjectId = projectId, }; return(View(vm)); }
public ActionResult Edit(ProjectBillingViewModel projectBilling) { if (ModelState.IsValid) { if (!DoIHaveAccessToProject(projectBilling.ProjectId)) { return(RedirectToAction("NotAuthorized", "Error", new { area = "" })); } var selectedBilling = _projectBillingRepository.Get(projectBilling.Id); if (projectBilling.Document != null && projectBilling.Document.ContentLength > 0) { if (selectedBilling != null) { selectedBilling.ProjectId = projectBilling.ProjectId; selectedBilling.Amount = projectBilling.Amount; selectedBilling.BillingHours = projectBilling.BillingHours; selectedBilling.BillingDate = projectBilling.BillingDate; selectedBilling.Comments = projectBilling.Comments; try { var fileName = projectBilling.Document.FileName; var path = Path.Combine(Server.MapPath("~/Uploads"), Path.GetFileName(fileName)); projectBilling.Document.SaveAs(path); selectedBilling.DocumentPath = fileName; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message; } } } if (selectedBilling != null) { selectedBilling.UpdatedByUserId = WebUser.Id; _projectBillingRepository.Update(selectedBilling); _unitOfWork.Commit(); } return(RedirectToAction("Details", "Projects", new { Id = projectBilling.ProjectId })); } ViewBag.ProjectId = new SelectList(_projectRepository.GetAll(), "Id", "Title", projectBilling.ProjectId); return(View(projectBilling)); }