public JsonResult AddVendorUserRegistration(VendorUserRegistrationModel collection) { try { var data = new tbl_VendorUserRegistration { DeviceTokenId = collection.DeviceTokenId, VendorUserID = collection.VendorUserID, VendorName = collection.VendorName, VendorAddress = collection.VendorAddress, VendorContactNo = collection.VendorContactNo, VendorEmailID = collection.VendorEmailID, VendorNatureOfWork = collection.VendorNatureOfWork, VendorContractorSrNo = collection.VendorContractorSrNo, VendorContractorCoNo = collection.VendorContractorCoNo, VendorPassword = collection.VendorPassword, VendorRegistrationDate = DateTime.Now }; _DbWorkPermitSystemEntities.tbl_VendorUserRegistration.Add(data); _DbWorkPermitSystemEntities.SaveChanges(); ResultModel _objResult = new ResultModel(); _objResult.success = 1; _objResult.msg = "Save Successfully"; return(Json(_objResult, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ResultModel _objResult = new ResultModel(); _objResult.success = 0; _objResult.msg = ex.ToString(); return(Json(_objResult, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(VendorUserRegistrationModel collection) { try { CheckViewBagData(); var _objVendorUserRegistration = _DbWorkPermitSystemEntities.tbl_VendorUserRegistration.DefaultIfEmpty().Max(p => p == null ? 0 : p.VendorSrNo); ViewBag.VendorSrNo = _objVendorUserRegistration + 1; ViewBag.UserID = "M&M" + ViewBag.VendorSrNo; if (ModelState.IsValid) { var data = new tbl_VendorUserRegistration { VendorUserID = collection.VendorUserID, VendorName = collection.VendorName, VendorAddress = collection.VendorAddress, VendorContactNo = collection.VendorContactNo, VendorEmailID = collection.VendorEmailID, VendorNatureOfWork = collection.VendorNatureOfWork, VendorContractorSrNo = collection.VendorContractorSrNo, VendorContractorCoNo = collection.VendorContractorCoNo, VendorPassword = collection.VendorPassword, VendorRegistrationDate = DateTime.Now }; _DbWorkPermitSystemEntities.tbl_VendorUserRegistration.Add(data); _DbWorkPermitSystemEntities.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ContractorNameCombo = new SelectList(_DbWorkPermitSystemEntities.tbl_ContractorMaster, "ContractorSrNo", "ContractorName"); return(View()); } catch (Exception ex) { ResultModel _objResult = new ResultModel(); _objResult.success = 0; _objResult.msg = ex.ToString(); return(View()); } }