public ActionResult Register(RegisterCustomerModel model) { var result = new Dictionary<string, object> { ["isSuccess"] = false, ["error"] = "Something was wrong. Customer has not been added to the database" }; if (!this.ModelState.IsValid) return this.Json(result, JsonRequestBehavior.DenyGet); var hashedPassword = HelperConverter.DoubleMD5Hash(model.Password); var helper = new HelperRepository(); var insertedCustomerId = helper.InsertCustomer( model.FirstName, model.MiddleName, model.LastName); helper.InsertUser(insertedCustomerId, model.Email, hashedPassword, model.RoleId); result["success"] = $"Customer {model.FirstName} {model.LastName} has successfully added to the database"; result["model"] = HelperConverter.GetCustomerRowJsonString(insertedCustomerId); result["isSuccess"] = true; return this.Json(result, JsonRequestBehavior.DenyGet); }
public ActionResult Signup(RegisterCustomerModel model) { model.RoleId = 1; var message = "Something was wrong. You are has not been registered"; if (!this.ModelState.IsValid) return this.Json(message, JsonRequestBehavior.DenyGet); var hashedPassword = HelperConverter.DoubleMD5Hash(model.Password); var helper = new HelperRepository(); var insertedCustomerId = helper.InsertCustomer( model.FirstName, model.MiddleName, model.LastName); helper.InsertUser(insertedCustomerId, model.Email, hashedPassword, model.RoleId); return this.RedirectToAction("Login", "Account"); }