public ActionResult RegisterCustomer(LicensedCustomers model) { try { UserBase userBase = new UserBase(); userBase.ID = model.Id; userBase.FirstName = model.FirstName; userBase.LastName = model.LastName; userBase.UserName = model.UserName; userBase.EMail = model.EMail; userBase.Password = model.Password; userBase.Phone = model.Phone; userBase.Country = model.Country; userBase.State = model.State; userBase.City = model.City; userBase.Zip = model.Zip; userBase.LicenseExpiryDate = model.LicenseExpiryDate; userBase.CustomerLogo = model.CustomerLogo; userBase.CustomerRoles = model.Roles; actionResult = accountAction.Customers_InsertUpdate(userBase); if (actionResult.IsSuccess) { TempData["SuccessMessage"] = "Customer " + (model.Id > 0 ? "updated" : "created") + " successfully."; } else { TempData["ErrorMessage"] = "Error in " + (model.Id > 0 ? "updating" : "saving") + " customer."; } } catch (Exception ex) { TempData["ErrorMessage"] = "Error in " + (model.Id > 0 ? "updating" : "saving") + " customer."; } return(RedirectToAction("RegisterCustomer")); }
public ActionResult RegisterCustomer(int?Id = 0) { LicensedCustomers model = new LicensedCustomers(); UserBase userBase = new UserBase(); actionResult = accountAction.Customer_LoadById(); if (actionResult.IsSuccess) { DataRow dr = actionResult.dtResult.Rows[0]; model.Id = dr["ID"] != DBNull.Value ? Convert.ToInt32(dr["ID"]) : 0; model.FirstName = dr["FirstName"] != DBNull.Value ? dr["FirstName"].ToString() : ""; model.LastName = dr["LastName"] != DBNull.Value ? dr["LastName"].ToString() : ""; model.UserName = dr["UserName"] != DBNull.Value ? dr["UserName"].ToString() : ""; model.EMail = dr["Email"] != DBNull.Value ? dr["Email"].ToString() : ""; model.UserName = dr["UserName"] != DBNull.Value ? dr["UserName"].ToString() : ""; model.Roles = dr["Roles"] != DBNull.Value ? dr["Roles"].ToString() : ""; model.Country = dr["Country"] != DBNull.Value ? Convert.ToInt32(dr["Country"]) : 0; model.State = dr["State"] != DBNull.Value ? Convert.ToInt32(dr["State"]) : 0; model.City = dr["City"] != DBNull.Value ? dr["City"].ToString() : ""; model.Zip = dr["Zip"] != DBNull.Value ? dr["Zip"].ToString() : ""; model.CustomerLogo = dr["CustomerLogo"] != DBNull.Value ? dr["CustomerLogo"].ToString() : ""; if (dr["LicenseExpiryDate"] != DBNull.Value) { model.LicenseExpiryDate = Convert.ToDateTime(dr["LicenseExpiryDate"]); } } actionResult = accountAction.Menus_LoadAll(); if (actionResult.IsSuccess) { model.MenusList = CommonMethods.ConvertTo <Menus>(actionResult.dtResult); } model.CountryList = new List <Country>(); model.StateList = new List <State>(); actionResult = accountAction.Countries_LoadAll(); if (actionResult.IsSuccess) { model.CountryList = CommonMethods.ConvertTo <Country>(actionResult.dtResult); } if (model.CountryList.Count > 0 && (model.Country == 0 || model.Country == null)) { userBase.Country = Convert.ToInt32(model.CountryList[0].ID); } else { userBase.Country = Convert.ToInt32(model.Country); } actionResult = accountAction.State_LoadByCountryId(userBase); if (actionResult.IsSuccess) { model.StateList = CommonMethods.ConvertTo <State>(actionResult.dtResult); } return(View(model)); }
public JsonResult GetStateListByCountryId(int CountryId = 0) { LicensedCustomers model = new LicensedCustomers(); model.StateList = new List <State>(); UserBase userBase = new UserBase(); if (CountryId > 0) { userBase.Country = Convert.ToInt32(CountryId); actionResult = accountAction.State_LoadByCountryId(userBase); if (actionResult.IsSuccess) { model.StateList = CommonMethods.ConvertTo <State>(actionResult.dtResult); } } return(Json(model)); }