public ActionResult Update(SubContractorFormViewModel viewModel) { if (!ModelState.IsValid) { return(View("SubContractorForm", viewModel)); } var userId = User.Identity.GetUserId(); var contractor = db.SubContractors.SingleOrDefault(s => s.SubcontractorId == viewModel.Id); contractor.Region = viewModel.Region; contractor.AffiliateRegion = viewModel.AffiliateRegion; contractor.OrgName = viewModel.OrgName; contractor.Director = viewModel.Director; contractor.City = viewModel.City; contractor.State = viewModel.State; contractor.County = viewModel.County; contractor.ZipCode = viewModel.ZipCode; contractor.EIN = viewModel.EIN; contractor.Address1 = viewModel.Address1; contractor.PoBox = viewModel.PoBox; contractor.Active = viewModel.Active; db.SaveChanges(); return(RedirectToAction("Reports", "Subcontractor")); }
public ActionResult Create(SubContractorFormViewModel viewModel) { if (!ModelState.IsValid) { return(View("SubContractorForm", viewModel)); } var contractor = new SubContractor { SubcontractorId = Guid.NewGuid(), AdministratorId = User.Identity.GetUserId(), Region = viewModel.Region, AffiliateRegion = viewModel.AffiliateRegion, OrgName = viewModel.OrgName, Director = viewModel.Director, City = viewModel.City, State = viewModel.State, County = viewModel.County, ZipCode = viewModel.ZipCode, EIN = viewModel.EIN, Address1 = viewModel.Address1, PoBox = viewModel.PoBox, Active = viewModel.Active, SubmittedDate = DateTime.Now }; db.SubContractors.Add(contractor); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult Create() { var viewModel = new SubContractorFormViewModel { Heading = "Create New Subcontractor" }; return(View("SubContractorForm", viewModel)); }
public ActionResult Edit(Guid id) { var org = db.SubContractors.SingleOrDefault(s => s.SubcontractorId == id); var viewModel = new SubContractorFormViewModel { Heading = "Edit Subcontractor Information", Id = org.SubcontractorId, Region = org.Region, AffiliateRegion = org.AffiliateRegion, Director = org.Director, City = org.City, State = org.State, County = org.County, ZipCode = org.ZipCode, EIN = org.EIN, Address1 = org.Address1, PoBox = org.PoBox, OrgName = org.OrgName, Active = org.Active, SubmittedDate = DateTime.Now }; return(View("SubContractorForm", viewModel)); }