public ActionResult Registration(ConsumerRegistration model) { //String ConsumerID if (Session["Login"] != null) { LoginSession loginsession = (LoginSession)Session["Login"]; ViewBag.CompanyLogo = loginsession.CompanyLogo; ViewBag.Layout1 = BAL.Common.LayoutType(loginsession.UserType); String actionName = this.ControllerContext.RouteData.Values["action"].ToString(); String controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ViewBag.Menu = BAL.Common.GetActiveMenu(controllerName, BAL.Common.LayoutType(loginsession.UserType)); ViewBag.RoleName = loginsession.RoleName; ViewBag.Security = new SelectList(BAL.SecurityQuestion.SecurityQuestionDDR(), "Value", "Text"); if (String.IsNullOrEmpty(model.UserName.ToString())) { ModelState.AddModelError("UserID", "Please Enter UserID"); } if (String.IsNullOrEmpty(model.ConsumerID.ToString())) { ModelState.AddModelError("Please", "Try again"); } try { if (ModelState.IsValid) { //------------------------------------------------------------- MembershipCreateStatus createStatus; System.Web.Security.Membership.CreateUser(model.UserName, model.Password, model.UserName, model.HintQut, model.HintAns, isApproved: true, providerUserKey: null, status: out createStatus); if (createStatus == MembershipCreateStatus.Success) { String User_ID = System.Web.Security.Membership.GetUser(model.UserName).ProviderUserKey.ToString(); if (User_ID != null) { model.MemberShipId = User_ID; model.RoleName = "VIEW"; model.CreateBy = Convert.ToInt64(loginsession.UserID); // model.ConsumerType = "2"; if (BAL.ConsumerModel.CreateConsumerRegistration(model)) { if (model.RoleName != null) { Roles.AddUserToRole(model.UserName, model.RoleName); } return Json(new { result = 1, message = "Record was successfully Saved!", Type = model.ConsumerType }); } else { return Json(new { result = 0, message = "Record Save Failure, Try again" }); } } else { return Json(new { result = 0, message = "Record Save Failure, Try again" }); } } else { return Json(new { result = 0, message = "Duplicate EmailID " }); } } else { String errorMessage = String.Empty; String exception = String.Empty; foreach (var modelStateVal in ViewData.ModelState.Values) { foreach (var error in modelStateVal.Errors) { errorMessage = error.ErrorMessage; exception = error.Exception.ToString(); } } return Json(new { result = 0, message = "ErrorMessage" + ":" + exception }); } } catch (Exception ex) { return Json(new { result = 0, message = "ErrorMessage" + ":" + ex.StackTrace.ToString() }); } } else { return RedirectToAction("Index", "Home"); } }
public static Boolean CreateConsumerRegistration(ConsumerRegistration consumer) { Boolean flag = false; try { IRegistration objtext = new BALConsumerRegister(); flag = objtext.CreateRegistration(consumer); } catch (Exception ex) { throw; } return flag; }//CreateConsumerRegistration