public ActionResult Index(BusinessProfilePage currentPage, BusinessProfileModel businessProfile) { 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/BusinessProfile.cshtml", new BusinessProfileViewModel(currentPage) { BusinessProfile = businessProfile, IsLoginBankId = !string.IsNullOrEmpty(SiteUser.SerialNumber) })); } var customer = UserManager.GetActiveCustomer(HttpContext); if (customer != null) { var result = _organizationRepository.UpdateBusinessProfile(new BusinessProfile { CustomerId = customer.CustomerId, Id = businessProfile.Id, Name = businessProfile.Name, Rows = businessProfile.Rows.ToArray() }, customer.CustomerNo); 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["UpdateInfoSuccess"] = true; TempData["UpdateBusinessProfileSuccess"] = true; return(RedirectToAction("Index", new { node = settingPage.MyAccountLink })); } } } } } var viewModel = new BusinessProfileViewModel(currentPage) { BusinessProfile = businessProfile, IsLoginBankId = !string.IsNullOrEmpty(SiteUser.SerialNumber) }; ViewBag.Message = "Uppdateringen lyckades inte. Försök igen!"; return(View("~/Views/Organization/BusinessProfile.cshtml", viewModel)); }
public IHttpActionResult InsertBusinessProfileData(BusinessProfileModel model) { var response = new DataResponse <EntityBusinessProfile>(); EntityBusinessProfile entity = new EntityBusinessProfile(); if (ModelState.IsValid) { entity.BusinessName = model.BusinessName; entity.Description = model.Description; entity.Address = model.Address; entity.About = model.About; entity.DomainUrl = model.DomainUrl; entity.City = model.City; entity.State = model.State; entity.Country = model.Country; entity.IsActive = model.IsActive; entity.OtherEmails = model.OtherEmails; entity.DateRange = model.DateRange; entity.SalesGroup = model.SalesGroup; entity.CreatedBy = CurrentUserId; entity.UpdatedBy = CurrentUserId; entity.RelativeUrl = model.RelativeUrl.Replace(" ", "-"); entity.Id = model.Id; entity.OtherEmails = string.IsNullOrEmpty(model.OtherEmails) ? null : Regex.Replace(model.OtherEmails, @"[\[\]\""]+", ""); if (!string.IsNullOrEmpty(model.DomainUrl)) { model.DomainUrl = model.DomainUrl.Replace(" ", "-"); } if (model.Id > 0) { response = new RepositoryBusinessProfiles().Update(entity); } return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }