public ActionResult RegisterBusiness(BusinessRegisterModel model) { ViewBag.Register = "Register as a business"; ViewBag.RegisterAction = "Register"; ViewBag.Message = "Business."; if (!model.TermsAndConditions) { ModelState.AddModelError("TermsAndConditions", "You must agree to the terms and conditions to register."); } if (ModelState.IsValid) { if (model.Logo != null) { // Attempt to register the user try { var trmservice = new WebService.WCFWebServiceJson(); var util = new Utilities(); var business = new BusinessUser { Logo= util.RemoveSpaces(model.BusinessName) + "/" + model.Logo.FileName, UserName = model.UserName, Password = model.Password, UserType = DomainModel.Entities.User.UserTypeList.Business, BusinessName = model.BusinessName, BusinessType = trmservice.GetAllBusinessTypes().Where(x => x.BusinessTypeId == model.BusinessType).FirstOrDefault(), BusinessTypeId = model.BusinessType, Address1 = model.Address1, Address2 = model.Address2, City = model.City, PostCode = model.PostCode, Country = model.Country, TermsAndConditionsAccepted = model.TermsAndConditions, CreatedDate = DateTime.Now }; if (trmservice.RegisterBusiness(business, model.Logo)) { WebSecurity.Login(model.UserName, model.Password); return RedirectToAction("RegisterBusinessSuccess", "Account"); } } catch (MembershipCreateUserException e) { ModelState.AddModelError("Error registering business", ErrorCodeToString(e.StatusCode)); } catch (Exception e) { ModelState.AddModelError("Generic Error", e.ToString()); } } else { ModelState.AddModelError("MissingProfileImage", "Please select a profile image."); } } // If we got this far, something failed, redisplay form return View(model); }