public UserModel SaveUser(UserModel _objdata) { tbl_All_User _objuser = new tbl_All_User(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objuser.int_id = (int)_objdata.int_id; _objuser.int_User_Type = _objdata.intModuleTypeId; _objuser.v_FirstName = _objdata.strFirstName; _objuser.v_LastName = _objdata.strLastName; _objuser.v_EmailId = _objdata.strEmailId; _objuser.v_MobileNo = _objdata.strMobileNo; _objuser.int_CountryId = _objdata.intCityId; _objuser.int_StateId = _objdata.intStateId; _objuser.int_CityId = _objdata.intCityId; _objuser.v_address = _objdata.strAddress; _objuser.v_Password = _objdata.strPassword; _objuser.dt_CreatedOn = DateTime.Now; _objuser.b_IsActive = true; dataContext.tbl_All_User.Add(_objuser); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "User save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public object UserSignUp(UserModel _objdata) { tbl_All_User _objuser = new tbl_All_User(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objuser.int_id = (int)_objdata.int_id; _objuser.int_User_Type = _objdata.intModuleTypeId; _objuser.v_FirstName = _objdata.strFirstName; _objuser.v_LastName = _objdata.strLastName; _objuser.v_EmailId = _objdata.strEmailId; _objuser.v_MobileNo = _objdata.strMobileNo; _objuser.int_CountryId = _objdata.intCountryId; _objuser.int_StateId = _objdata.intStateId; _objuser.int_CityId = _objdata.intCityId; _objuser.v_address = _objdata.strAddress; _objuser.v_Pin = _objdata.strPin; _objuser.v_Password = _objdata.strPassword; _objuser.dt_CreatedOn = DateTime.Now; _objuser.b_IsActive = true; dataContext.tbl_All_User.Add(_objuser); dataContext.SaveChanges(); UserModel _model = new UserModel(); _model.intUserId = _objuser.int_id; dataContext.Database.Connection.Close(); if (_model.intUserId != 0) { return new ResponseModel { StatusCode = (int)CCommon.StatusCode.Success, StatusMessaage = CCommon.StatusCode.Success.ToString(), data = "User save sucessfully." } } ; else { return new ResponseModel { StatusCode = (int)CCommon.StatusCode.Success, StatusMessaage = CCommon.StatusCode.Success.ToString(), data = "something went wrong" } }; } } catch (Exception ex) { throw ex; } }
public object UpdateUser(UserModel _objdata) { tbl_All_User _objproduct = new tbl_All_User(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_All_User.Where(x => x.int_id == _objdata.intUserId).FirstOrDefault(); if (_query != null) { tbl_All_User _log = new tbl_All_User(); _log = dataContext.tbl_All_User.Where(x => x.int_id == _objdata.intUserId).FirstOrDefault(); _log.v_FirstName = _objdata.strFirstName; _log.v_LastName = _objdata.strLastName; _log.v_EmailId = _objdata.strEmailId; _log.v_MobileNo = _objdata.strMobileNo; _log.int_CountryId = _objdata.intCityId; _log.int_StateId = _objdata.intStateId; _log.int_CityId = _objdata.intCityId; _log.v_address = _objdata.strAddress; _log.v_Password = _objdata.strPassword; _log.dt_CreatedOn = DateTime.Now; _log.b_IsActive = true; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } } return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.Success, StatusMessaage = CCommon.StatusCode.Success.ToString(), data = "User update sucessfully." }); } catch (Exception) { throw; } }