public async Task <ActionResult> Edit(ManageRegionModel Region) { Region.EventAction = 'U'; Region.UserId = CurrentUser.UserId; var response = await _Region.AddUpdateRegion(Region); TempData["response"] = response; return(RedirectToAction("Index")); }
public async Task <ActionResult> Create() { ManageRegionModel MR = new ManageRegionModel(); MR.StateList = new SelectList(_Dropdown.BindState(), "Value", "Text"); if (CurrentUser.UserTypeName.ToLower() == "super admin") { MR.IsAdmin = true; MR.CompanyList = new SelectList(await CommonModel.GetCompanies(), "Name", "Text"); } return(View(MR)); }
public async Task <ActionResult> Create(ManageRegionModel Region) { Region.EventAction = 'I'; Region.UserId = CurrentUser.UserId; if (CurrentUser.UserTypeName.ToLower() == "company") { Region.CompanyId = CurrentUser.CompanyId; } var response = await _Region.AddUpdateRegion(Region); TempData["response"] = response; return(RedirectToAction("Index")); }
public async Task <ResponseModel> AddUpdateRegion(ManageRegionModel Region) { var statesList = new List <StateModel>(); if (Region.SelectedStates != null) { for (int i = 0; i < Region.SelectedStates.Count; i++) { var state = new StateModel { St_ID = Region.SelectedStates[i].ToString() }; statesList.Add(state); } } string xml = ""; if (Region.SelectedStates != null) { XmlSerializer StateDetails = new XmlSerializer(statesList.GetType()); using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { StateDetails.Serialize(writer, statesList); xml = sww.ToString(); } } xml = xml.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", ""); } List <SqlParameter> sp = new List <SqlParameter>(); SqlParameter param = new SqlParameter("@REGIONID", ToDBNull(Region.RegionId)); sp.Add(param); param = new SqlParameter("@REGIONNAME", ToDBNull(Region.RegionName)); sp.Add(param); param = new SqlParameter("@REMARKS", ToDBNull(Region.Remarks)); sp.Add(param); param = new SqlParameter("@User", ToDBNull(Region.UserId)); sp.Add(param); param = new SqlParameter("@CompId", ToDBNull(Region.CompanyId)); sp.Add(param); param = new SqlParameter("@STATEXML", ToDBNull(xml)); sp.Add(param); param = new SqlParameter("@Action", (object)Region.EventAction); sp.Add(param); param = new SqlParameter("@IsActive", (object)(Region.IsActive)); sp.Add(param); var sql = "ADDOREDITREGION @REGIONID,@REGIONNAME,@REMARKS,@User,@CompId, @STATEXML,@Action,@IsActive"; var res = await _Context.Database.SqlQuery <ResponseModel>(sql, sp.ToArray()).SingleOrDefaultAsync(); if (res.ResponseCode == 0) { res.IsSuccess = true; } else { res.IsSuccess = false; } return(res); }