public async Task <ActionResult> ContractsCreate(EditContractorContractsViewModel model) { if (ModelState.IsValid) { Contract contract = (Contract)model.GetContract(); contract.ContractorID = model.ContractorID; contract.CustomerID = model.CustomerID; try { //contract.CreationDate = DateTime.UtcNow; //contract.CreationUser = System.Web.HttpContext.Current.User.Identity.Name; await contractRepository.CreateAsync(contract); return(RedirectToAction("Contracts", "Contractors", new { id = model.ContractorID })); } catch (Exception e) { var errors = string.Join(",", e.Message); ModelState.AddModelError(string.Empty, errors); } } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> ContractsEdit(EditContractorContractsViewModel model) { if (ModelState.IsValid) { Contract contract = model.GetContract(); try { //Contract.ModifiedDate = DateTime.UtcNow; //Contract.ModifiedUser = System.Web.HttpContext.Current.User.Identity.Name; await contractRepository.UpdateAsync(contract); return(RedirectToAction("Contracts", "Contractors", new { id = model.ContractorID })); } catch (Exception e) { var errors = string.Join(",", e.Message); ModelState.AddModelError(string.Empty, errors); } } return(View(model)); }