public object ChangePassword(int UserId, string ChangePassword, int int_moduleType_id, string OldPassword) { try { var _userPswd = dataContext.tbl_All_User.Where(a => a.int_id == UserId && a.int_User_Type == int_moduleType_id).FirstOrDefault(); if (_userPswd != null) { if (_userPswd.v_Password != OldPassword) { return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.Fail, StatusMessaage = CCommon.StatusCode.Fail.ToString(), data = "Incorrect Old Password." }); } else { _userPswd.v_Password = ChangePassword; } } int Result = dataContext.SaveChanges(); return(new ResponseModel { StatusCode = Result != 0 ? (int)CCommon.StatusCode.Success : (int)CCommon.StatusCode.Notsaved, StatusMessaage = Result != 0 ? CCommon.StatusCode.Success.ToString() : CCommon.StatusCode.Notsaved.ToString(), data = "" }); } catch (Exception ex) { CMail.SendSystemGeneratedMailSync(CCommon.strAdminEmailID, "TRACKING-ERROR-MAIL", ex.ToString(), CCommon.strEmailFrom, true); return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.ExceptionOccured, StatusMessaage = CCommon.StatusCode.ExceptionOccured.ToString(), data = "" }); } }
public StateModel UpdateState(StateModel _objdata) { tbl_States _objproduct = new tbl_States(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_States.Where(x => x.int_Id == _objdata.intStateId).FirstOrDefault(); if (_query != null) { tbl_States _log = new tbl_States(); _log = dataContext.tbl_States.Where(x => x.int_Id == _objdata.intStateId).FirstOrDefault(); _log.v_State = _objdata.strStateName; _log.int_CountryId = _objdata.intCountryId; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "State Updated sucessfully."; return(_objdata); } } catch (Exception ex) { throw ex; } }
public CountryModel UpdateCountry(CountryModel _objdata) { tbl_Countries _objCountry = new tbl_Countries(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_Countries.Where(x => x.int_Id == _objdata.intCountryId).FirstOrDefault(); if (_query != null) { tbl_Countries _objTemp = new tbl_Countries(); _objTemp = dataContext.tbl_Countries.Where(x => x.int_Id == _objdata.intCountryId).FirstOrDefault(); _objTemp.v_country = _objdata.strCountryName; _objTemp.v_currency = _objdata.strCourncy; _objTemp.v_currency_symbol = _objdata.strCourncySymbol; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "Country updated sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public CountryModel SaveCountry(CountryModel _objdata) { tbl_Countries _objCountry = new tbl_Countries(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objCountry.v_country = _objdata.strCountryName; _objCountry.v_currency = _objdata.strCourncy; _objCountry.v_currency_symbol = _objdata.strCourncySymbol; _objCountry.b_IsActive = true; dataContext.tbl_Countries.Add(_objCountry); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "Country save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public CityModel DeleteCity(int intCityId) { CityModel _objdata = new CityModel(); tbl_Cities _objCity = new tbl_Cities(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_Cities.Where(x => x.int_Id == intCityId).FirstOrDefault(); if (_query != null) { tbl_Cities _log = new tbl_Cities(); _log = dataContext.tbl_Cities.Where(x => x.int_Id == intCityId).FirstOrDefault(); _log.b_flag = false; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "City deleted sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public ProductModal DeleteProduct(int intProductId) { ProductModal _objdata = new ProductModal(); tbl_Products _objproduct = new tbl_Products(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_Products.Where(x => x.int_id == intProductId).FirstOrDefault(); if (_query != null) { tbl_Products _log = new tbl_Products(); _log = dataContext.tbl_Products.Where(x => x.int_id == intProductId).FirstOrDefault(); _log.b_IsActive = false; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "Product updated sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public StateModel SaveState(StateModel _objdata) { tbl_States _objState = new tbl_States(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objState.v_State = _objdata.strStateName; _objState.int_CountryId = _objdata.intCountryId; _objState.dt_Created_On = DateTime.Now; _objState.b_IsActive = true; dataContext.tbl_States.Add(_objState); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "State save sucessfully."; return(_objdata); } } catch (Exception ex) { throw ex; } }
public BrandModel UpdateBrand(BrandModel _objdata) { tbl_Brands _objBrand = new tbl_Brands(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_Brands.Where(x => x.int_id == _objdata.intBrandId).FirstOrDefault(); if (_query != null) { tbl_Brands _log = new tbl_Brands(); _log = dataContext.tbl_Brands.Where(x => x.int_id == _objdata.intBrandId).FirstOrDefault(); _log.v_name = _objdata.strBrandName; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "Brand updated sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public StateModel DeleteState(int intStateId) { StateModel _objdata = new StateModel(); tbl_States _objState = new tbl_States(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_States.Where(x => x.int_Id == intStateId).FirstOrDefault(); if (_query != null) { tbl_States _log = new tbl_States(); _log = dataContext.tbl_States.Where(x => x.int_Id == intStateId).FirstOrDefault(); _log.b_IsActive = false; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "State deleted sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public BrandModel DeleteBrand(int intBrandId) { BrandModel _objdata = new BrandModel(); tbl_Brands _objBrand = new tbl_Brands(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_Brands.Where(x => x.int_id == intBrandId).FirstOrDefault(); if (_query != null) { tbl_Brands _log = new tbl_Brands(); _log = dataContext.tbl_Brands.Where(x => x.int_id == intBrandId).FirstOrDefault(); // _log.b_IsActive = false; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "Brand deleted sucessfully."; return(_objdata); } } catch (Exception ex) { throw ex; } }
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 PostLogout(Postloginreq _login) { try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); tbl_OTP _logoutInput = dataContext.tbl_OTP.Single(e => e.int_user_id == _login.intloginId && e.dt_logout_time == null); _logoutInput.dt_logout_time = DateTime.Now; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.Success, StatusMessaage = CCommon.StatusCode.Success.ToString(), data = "" }); } } catch (Exception ex) { CMail.SendSystemGeneratedMailSync(CCommon.strAdminEmailID, "TRACKING-ERROR-MAIL", ex.ToString(), CCommon.strEmailFrom, true); return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.ExceptionOccured, StatusMessaage = CCommon.StatusCode.ExceptionOccured.ToString(), data = "" }); } }
public CategoryModel UpdateCategory(CategoryModel _objdata) { tbl_category _objcategory = new tbl_category(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_category.Where(x => x.int_id == _objdata.intCategoryId).FirstOrDefault(); if (_query != null) { tbl_category _log = new tbl_category(); _log = dataContext.tbl_category.Where(x => x.int_id == _objdata.intCategoryId).FirstOrDefault(); _log.v_category = _objdata.strCategoryName; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "Category updated sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public object PostLogin(Postloginreq _login) { try { Random generator = new Random(); string number = generator.Next(1, 10000).ToString("D4"); string strMessage = "Your OTP for Just Cool App is :" + number + ". Regards Corvi.com"; using (newconecommerce dataContext = new newconecommerce()) { var query = (from x in dataContext.tbl_OTP where x.int_user_id == _login.intloginId && x.dt_logout_time == null select x.int_user_id).FirstOrDefault(); if (query != null) { return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.Fail, StatusMessaage = CCommon.StatusCode.Fail.ToString(), data = "Already logged in with other device." }); } else { dataContext.Database.Connection.Open(); tbl_OTP _objLoginInput = new tbl_OTP(); _objLoginInput.int_moduleType_id = _login.intModuleTypeId; _objLoginInput.int_user_id = _login.intloginId; _objLoginInput.int_OTP = Convert.ToInt32(number); _objLoginInput.dt_OTP_created = DateTime.Now; _objLoginInput.dt_login_time = DateTime.Now; _objLoginInput.v_device_id = _login.strDeviceId; _objLoginInput.v_device_token = _login.strDevicetoken; _objLoginInput.v_device_token = _login.strDevicemode; _objLoginInput.dt_created_on = DateTime.Now; dataContext.tbl_OTP.Add(_objLoginInput); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.Success, StatusMessaage = CCommon.StatusCode.Success.ToString(), data = "Login success" }); } } } catch (Exception ex) { CMail.SendSystemGeneratedMailSync(CCommon.strAdminEmailID, "TRACKING-ERROR-MAIL", ex.ToString(), CCommon.strEmailFrom, true); return(new ResponseModel { StatusCode = (int)CCommon.StatusCode.ExceptionOccured, StatusMessaage = CCommon.StatusCode.ExceptionOccured.ToString(), data = "Failed to login." }); } }
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 ProductModal UpdateProduct(ProductModal _objdata) { tbl_Products _objproduct = new tbl_Products(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); var _query = dataContext.tbl_Products.Where(x => x.int_id == _objdata.intProductId).FirstOrDefault(); if (_query != null) { tbl_Products _log = new tbl_Products(); _log = dataContext.tbl_Products.Where(x => x.int_id == _objdata.intProductId).FirstOrDefault(); _log.v_name = _objdata.strProductName; _log.fl_price = _objdata.dblPrice; _log.int_quantity = _objdata.intQuantity; _log.fl_weight = _objdata.dblWeight; _log.fl_length = _objdata.flLength; _log.fl_breadth = _objdata.flBreadth; _log.fl_height = _objdata.flHeight; _log.fl_GST = _objdata.flGST; _log.fl_QtyDiscount = _objdata.dblQtyDiscount; _log.int_BrandsId = _objdata.intBrands; _log.int_CategoryId = _objdata.intCategory; _log.v_image = _objdata.strProductName; _log.v_description_info = _objdata.strDescription; dataContext.SaveChanges(); dataContext.Database.Connection.Close(); } _objdata.StatusMessaage = "Product updated sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
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; } }
public BrandModel SaveBrand(BrandModel _objdata) { tbl_Brands _objBrand = new tbl_Brands(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objBrand.v_name = _objdata.strBrandName; dataContext.tbl_Brands.Add(_objBrand); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "Brand save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public CategoryModel SaveCategory(CategoryModel _objdata) { tbl_category _objCategory = new tbl_category(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objCategory.v_category = _objdata.strCategoryName; _objCategory.b_IsActive = true; dataContext.tbl_category.Add(_objCategory); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "Category save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public CityModel SaveCity(CityModel _objdata) { tbl_Cities _objCity = new tbl_Cities(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objCity.v_City = _objdata.strCityName; _objCity.int_State_Id = _objdata.intStateId; _objCity.b_flag = true; dataContext.tbl_Cities.Add(_objCity); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "City save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public ProductModal SaveProduct(ProductModal _objdata) { tbl_Products _objproduct = new tbl_Products(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objproduct.v_name = _objdata.strProductName; _objproduct.fl_price = Convert.ToDouble(_objdata.dblPrice); _objproduct.int_quantity = _objdata.intQuantity; _objproduct.fl_weight = Convert.ToDouble(_objdata.dblWeight); _objproduct.fl_length = Convert.ToDouble(_objdata.flLength); _objproduct.fl_breadth = Convert.ToDouble(_objdata.flBreadth); _objproduct.fl_height = Convert.ToDouble(_objdata.flHeight); _objproduct.fl_GST = Convert.ToDouble(_objdata.flGST); _objproduct.fl_QtyDiscount = _objdata.dblQtyDiscount; _objproduct.int_BrandsId = _objdata.intBrands; _objproduct.int_CategoryId = _objdata.intCategory; _objproduct.v_image = _objdata.strImagePath; _objproduct.v_description_info = _objdata.strDescription; _objproduct.dt_created_on = DateTime.Now; _objproduct.b_IsActive = true; dataContext.tbl_Products.Add(_objproduct); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "Product save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }