public GodownViewModel() { //var COMPANY_ID = Convert.ToInt32(App.Current.Properties["Company_Id"].ToString()); var COMPANY_ID = 1; SelectedOpeningStock = new OpeningStockModel(); //if (App.Current.Properties["Action"] == "Edit") //{ // CreatVisible = "Collapsed"; // UpdVisible = "Visible"; // SelectedGosown = App.Current.Properties["GodownEdit"] as GodownModel; // //GetGodowns(COMPANY_ID); // App.Current.Properties["Action"] = ""; //} //else if (App.Current.Properties["Action"] == "View") //{ // SelectedGosown = App.Current.Properties["GodownView"] as GodownModel; // App.Current.Properties["Action"] = ""; //} //else { UpdVisible = "Collapsed"; CreatVisible = "Visible"; SelectedGosown = new GodownModel(); GetGodowns(COMPANY_ID); } }
public List <GodownModel> GetGodowns() { try { List <GodownModel> godowns = new List <GodownModel>(); var Data = _tRSEntities.GodownMasters.Where(x => x.IsActive == true).ToList(); foreach (var item in Data) { GodownModel model = new GodownModel { id = item.id, address = item.address, branchId = item.branchId, cityId = item.cityId, godownCode = item.godownCode, godownName = item.godownName, IsActive = item.IsActive, mobileNo = item.mobileNo, phoneNo = item.phoneNo, pincode = item.pincode, remark = item.remark, stateId = item.stateId, storageCapacity = item.storageCapacity }; godowns.Add(model); } return(godowns); } catch (Exception e) { throw e; } }
public GodownModel GetGodown(int id) { try { var Check = _tRSEntities.GodownMasters.Where(x => x.id == id && x.IsActive == true).FirstOrDefault(); if (Check != null) { GodownModel model = new GodownModel { id = Check.id, address = Check.address, branchId = Check.branchId, cityId = Check.cityId, godownCode = Check.godownCode, godownName = Check.godownName, IsActive = Check.IsActive, mobileNo = Check.mobileNo, phoneNo = Check.phoneNo, pincode = Check.pincode, remark = Check.remark, stateId = Check.stateId, storageCapacity = Check.storageCapacity }; return(model); } return(null); } catch (Exception e) { throw e; } }
public bool UpdateData(GodownModel model) { try { var Check = _tRSEntities.GodownMasters.Where(x => x.id == model.id && x.IsActive == true).FirstOrDefault(); if (Check != null) { Check.address = model.address; Check.branchId = model.branchId; Check.cityId = model.cityId; Check.godownCode = model.godownCode; Check.godownName = model.godownName; Check.IsActive = true; Check.mobileNo = model.mobileNo; Check.phoneNo = model.phoneNo; Check.pincode = model.pincode; Check.remark = model.remark; Check.stateId = model.stateId; Check.storageCapacity = model.storageCapacity; _tRSEntities.SaveChanges(); return(true); } return(false); } catch (Exception e) { throw e; } }
public bool SaveGodown(GodownModel model) { try { GodownMaster master = new GodownMaster { address = model.address, branchId = model.branchId, cityId = model.cityId, godownCode = model.godownCode, godownName = model.godownName, IsActive = true, mobileNo = model.mobileNo, phoneNo = model.phoneNo, pincode = model.pincode, remark = model.remark, stateId = model.stateId, storageCapacity = model.storageCapacity }; _tRSEntities.GodownMasters.Add(master); _tRSEntities.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
public HttpResponseMessage GodownAdd(GodownModel _GodownModel) { try { bool conn = false; conn = db.Database.Exists(); if (!conn) { ConnectionTools.changeToLocalDB(db); conn = db.Database.Exists(); } if (conn) { if (_GodownModel.GODOWN_ID == null || _GodownModel.GODOWN_ID == 0) { TBL_GODOWN gd = new TBL_GODOWN(); gd.COMPANY_ID = _GodownModel.COMPANY_ID; gd.GODOWN_NAME = _GodownModel.GODOWN_NAME; gd.GOSOWN_DESCRIPTION = _GodownModel.GOSOWN_DESCRIPTION; gd.IS_ACTIVE = _GodownModel.IS_ACTIVE; gd.IS_DELETE = false; gd.IS_DEFAULT_GODOWN = false; db.TBL_GODOWN.Add(gd); db.SaveChanges(); } else { var str = (from a in db.TBL_GODOWN where a.GODOWN_ID == _GodownModel.GODOWN_ID select a).FirstOrDefault(); str.COMPANY_ID = _GodownModel.COMPANY_ID; str.GODOWN_NAME = _GodownModel.GODOWN_NAME; str.GOSOWN_DESCRIPTION = _GodownModel.GOSOWN_DESCRIPTION; str.IS_ACTIVE = _GodownModel.IS_ACTIVE; str.IS_DELETE = false; str.IS_DEFAULT_GODOWN = false; db.SaveChanges(); } return(Request.CreateResponse(HttpStatusCode.OK, "ok")); } else { return(Request.CreateResponse(HttpStatusCode.ExpectationFailed)); } } catch (Exception ex) { throw; } finally { ConnectionTools.ChangeToRemoteDB(db); } }
public IHttpActionResult UpdateGodown(GodownModel model) { var Data = godownRepo.UpdateData(model); return(Ok(Data)); }
public IHttpActionResult SaveGodown(GodownModel model) { var Data = godownRepo.SaveGodown(model); return(Ok(Data)); }