public ActionResult Create(CompanyBranchViewModel companyBranchViewModel) { var organisationId = UserOrganisationId; var personnelId = UserPersonnelId; var centreId = UserCentreId; if (ModelState.IsValid) { companyBranchViewModel.CompanyBranch.OrganisationId = organisationId; companyBranchViewModel.CompanyBranch.CreatedBy = personnelId; companyBranchViewModel.CompanyBranch.CentreId = centreId; companyBranchViewModel.CompanyBranch = _nidanBusinessService.CreateCompanyBranch(organisationId, companyBranchViewModel.CompanyBranch); return(RedirectToAction("Edit", "Company", new { id = companyBranchViewModel.CompanyBranch.CompanyId })); } companyBranchViewModel.Sectors = new SelectList(_nidanBusinessService.RetrieveSectors(organisationId, e => true).ToList(), "SectorId", "Name"); return(View(companyBranchViewModel)); }
// GET: Company/Edit/{id} public ActionResult Edit(int?id) { var organisationId = UserOrganisationId; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var companyBranch = _nidanBusinessService.RetrieveCompanyBranch(organisationId, id.Value); var sectors = _nidanBusinessService.RetrieveSectors(organisationId, e => true); var company = _nidanBusinessService.RetrieveCompany(organisationId, companyBranch.CompanyId); var viewModel = new CompanyBranchViewModel() { Company = company, CompanyId = companyBranch.CompanyId, CompanyBranch = companyBranch, Sectors = new SelectList(sectors, "SectorId", "Name") }; return(View(viewModel)); }
public ActionResult Create(int?id) { var organisationId = UserOrganisationId; id = id ?? 0; var sectors = _nidanBusinessService.RetrieveSectors(organisationId, e => true); var company = _nidanBusinessService.RetrieveCompany(organisationId, id.Value); var viewModel = new CompanyBranchViewModel { Company = company, CompanyId = id.Value, Sectors = new SelectList(sectors, "SectorId", "Name"), CompanyBranch = new CompanyBranch() { CompanyId = company.CompanyId, Company = company } }; return(View(viewModel)); }