public ActionResult Index(CompanyInformationPage currentPage) { if (SiteUser == null) { return(View("~/Views/Organization/CompanyInformation.cshtml", new CompanyInformationViewModel(currentPage))); } var organization = UserManager.GetActiveCustomer(HttpContext); if (organization == null) { return(View("~/Views/Organization/CompanyInformation.cshtml", new CompanyInformationViewModel(currentPage))); } var companyInformation = _organizationRepository.GetCompanyInformation(organization.CustomerId) ?? new OrganisationInformation(); var viewModel = new CompanyInformationViewModel(currentPage) { CompanyInformation = new CompanyInformationModel { Address = companyInformation.Address, City = companyInformation.City, ZipCode = companyInformation.Zip, CompanyName = companyInformation.OrganisationName, Email = companyInformation.Email, PhoneMobile = companyInformation.PhoneMobile, PhoneWork = companyInformation.PhoneWork, Comment = companyInformation.Comment }, IsLoginBankId = !string.IsNullOrEmpty(SiteUser.SerialNumber) }; return(View("~/Views/Organization/CompanyInformation.cshtml", viewModel)); }
public IEnumerable <CompanyInformationViewModel> LoadCompanyInformation() { var model = new CompanyInformationViewModel(); using (var ctx = new VIPDCEntities()) { model.CompanyAddress1 = ctx.Configurations.Single(config => config.Key == ConfigurationKeys.CompanyAddress1).Value; model.CompanyAddress2 = ctx.Configurations.Single(config => config.Key == ConfigurationKeys.CompanyAddress2).Value; model.CompanyWebsite = ctx.Configurations.Single(config => config.Key == ConfigurationKeys.CompanyWebsite).Value; model.Fax = ctx.Configurations.Single(config => config.Key == ConfigurationKeys.CompanyFax).Value; model.Phone = ctx.Configurations.Single(config => config.Key == ConfigurationKeys.CompanyPhone).Value; model.CompanyName = ctx.Configurations.Single(config => config.Key == ConfigurationKeys.CompanyName).Value; } yield return(model); }
public ActionResult Index(CompanyInformationPage currentPage, CompanyInformationModel companyInformation) { if (string.IsNullOrEmpty(SiteUser?.SerialNumber)) { return(HttpNotFound()); } if (!ModelState.IsValid) { Response.StatusCode = 400; ViewBag.Message = "Some fields have invalid value. Please try again!"; return(View("~/Views/Organization/CompanyInformation.cshtml", new CompanyInformationViewModel(currentPage) { CompanyInformation = companyInformation, IsLoginBankId = !string.IsNullOrEmpty(SiteUser.SerialNumber) })); } var organization = UserManager.GetActiveCustomer(HttpContext); if (organization != null) { var result = _organizationRepository.UpdateCompanyInformation(new OrganisationInformation { OrganisationId = organization.CustomerId, Address = companyInformation.Address, City = companyInformation.City, Zip = companyInformation.ZipCode, OrganisationName = companyInformation.CompanyName, Email = companyInformation.Email, PhoneMobile = companyInformation.PhoneMobile, PhoneWork = companyInformation.PhoneWork, Comment = companyInformation.Comment }); if (result) { var startPage = _contentRepo.Get <StartPage>(ContentReference.StartPage); if (startPage != null) { if (!PageReference.IsNullOrEmpty(startPage.SettingsPage)) { var settingPage = _contentRepo.Get <SettingsPage>(startPage.SettingsPage); if (settingPage != null) { TempData["UpdateCompanyInformationSuccess"] = true; return(RedirectToAction("Index", new { node = settingPage.MyAccountLink })); } } } } } var viewModel = new CompanyInformationViewModel(currentPage) { CompanyInformation = companyInformation, IsLoginBankId = !string.IsNullOrEmpty(SiteUser.SerialNumber) }; ViewBag.Message = "Update company information is not successful. Please try again!"; return(View("~/Views/Organization/CompanyInformation.cshtml", viewModel)); }