public void DeleteAppUsersModulesByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { AppUsersModules appusermodule = (from c in dbContext.AppUsersModules where c.PK_AppUsersModules == id select c).FirstOrDefault(); if (appusermodule != null) { dbContext.Entry(appusermodule).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public void DeleteBranchByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { MstrBranches branch = (from c in dbContext.MstrBranches where c.PK_MstrBranches == id select c).FirstOrDefault(); if (branch != null) { dbContext.Entry(branch).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public void DeleteAgentByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { MstrAgency agent = (from c in dbContext.MstrAgency where c.PK_MstrAgency == id select c).FirstOrDefault(); if (agent != null) { dbContext.Entry(agent).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public MscItemCategory SaveItemCategory(MscItemCategory category) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingItemCategory = (from c in dbContext.MscItemCategory where c.PK_MscItemCategory == category.PK_MscItemCategory select c).FirstOrDefault(); if (existingItemCategory != null) { existingItemCategory.ItemCategory = category.ItemCategory; dbContext.Entry(existingItemCategory).State = EntityState.Modified; } else { dbContext.Entry(category).State = EntityState.Added; } dbContext.SaveChanges(); return category; } }
public MscIncentiveClass SaveIncentiveClass(MscIncentiveClass incentiveclass) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingIncentiveClass = (from c in dbContext.MscIncentiveClass where c.PK_MscIncentiveClass == incentiveclass.PK_MscIncentiveClass select c).FirstOrDefault(); if (existingIncentiveClass != null) { existingIncentiveClass.IncentiveClass = incentiveclass.IncentiveClass; dbContext.Entry(existingIncentiveClass).State = EntityState.Modified; } else { dbContext.Entry(incentiveclass).State = EntityState.Added; } dbContext.SaveChanges(); return incentiveclass; } }
public void DeleteItemCategoryByID(Int32 id) { using (IMsDBContext dbContext = new IMsDBContext()) { MscItemCategory itemcategory = (from c in dbContext.MscItemCategory where c.PK_MscItemCategory == id select c).FirstOrDefault(); if (itemcategory != null) { dbContext.Entry(itemcategory).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public TrxRawDataFromLogistics SaveUploadedDataFromLogistics(TrxRawDataFromLogistics rawdatatosave) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingRecord = (from c in dbContext.TrxRawDataFromLogistics where c.PK_trxRawDataFromLogistics == rawdatatosave.PK_trxRawDataFromLogistics select c).FirstOrDefault(); if (existingRecord != null) { existingRecord.dealername = rawdatatosave.dealername; existingRecord.serialno = rawdatatosave.serialno; existingRecord.modelno = rawdatatosave.modelno; existingRecord.dateuploaded = DateTime.Now; dbContext.Entry(existingRecord).State = EntityState.Modified; } else { dbContext.Entry(rawdatatosave).State = EntityState.Added; } dbContext.SaveChanges(); return rawdatatosave; } }
public void DeleteDealerByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { MstrDealer dealer = (from c in dbContext.MstrDealer where c.PK_MstrDealer == id select c).FirstOrDefault(); if (dealer != null) { dbContext.Entry(dealer).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public MstrModules SaveModule(MstrModules module) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingmodule = (from c in dbContext.MstrModules where c.PK_MstrModules == module.PK_MstrModules select c).FirstOrDefault(); if (existingmodule != null) { existingmodule.Name = module.Name; existingmodule.WithAdd = module.WithAdd; existingmodule.WithEdit = module.WithEdit; existingmodule.WithDelete = module.WithDelete; existingmodule.WithPost = module.WithPost; existingmodule.WithVoid = module.WithVoid; existingmodule.IsVisible = module.IsVisible; dbContext.Entry(existingmodule).State = EntityState.Modified; } else { if (module.PK_MstrModules == null) module.PK_MstrModules = Guid.NewGuid(); dbContext.Entry(module).State = EntityState.Added; } dbContext.SaveChanges(); return module; } }
public MstrAgency SaveAgent(MstrAgency agent) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingagent = (from c in dbContext.MstrAgency where c.PK_MstrAgency == agent.PK_MstrAgency select c).FirstOrDefault(); if (existingagent != null) { existingagent.IsActive = agent.IsActive; existingagent.Address = agent.Address; existingagent.Name = agent.Name; dbContext.Entry(existingagent).State = EntityState.Modified; } else { if (agent.PK_MstrAgency == null) agent.PK_MstrAgency = Guid.NewGuid(); dbContext.Entry(agent).State = EntityState.Added; } dbContext.SaveChanges(); return agent; } }
public void DeleteUploadedDataFromLogisticsByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { TrxRawDataFromLogistics existingrecord = (from c in dbContext.TrxRawDataFromLogistics where c.PK_trxRawDataFromLogistics == id select c).FirstOrDefault(); if (existingrecord != null) { dbContext.Entry(existingrecord).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public void DeleteSubClassificationByID(Int32 id) { using (IMsDBContext dbContext = new IMsDBContext()) { MscSubClassification subclassification = (from c in dbContext.MscSubClassification where c.PK_MscSubClassification == id select c).FirstOrDefault(); if (subclassification != null) { dbContext.Entry(subclassification).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public void DeleteSellOutFromAgencyByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { TrxSellOutFromAgency existingrecord = (from c in dbContext.TrxSellOutFromAgency where c.PK_TrxSellOutFromAgency == id select c).FirstOrDefault(); if (existingrecord != null) { dbContext.Entry(existingrecord).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public void DeleteModuleByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { MstrModules module = (from c in dbContext.MstrModules where c.PK_MstrModules == id select c).FirstOrDefault(); if (module != null) { dbContext.Entry(module).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public MstrItems SaveItems(MstrItems items) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingItems = (from c in dbContext.MstrItems where c.PK_MstrItems == items.PK_MstrItems select c).FirstOrDefault(); if (existingItems != null) { existingItems.AutoPerUnitIncentive = items.AutoPerUnitIncentive; existingItems.FK_MscItemCategory = items.FK_MscItemCategory; existingItems.FK_MscSubClassification = items.FK_MscSubClassification; existingItems.FK_MstrDealer = items.FK_MstrDealer; existingItems.IncrePerUnitIncentive = items.IncrePerUnitIncentive; existingItems.IsActive = items.IsActive; existingItems.ItemCode = items.ItemCode; existingItems.ItemDescription = items.ItemDescription; existingItems.Model = items.Model; existingItems.SerialNo = items.SerialNo; existingItems.SRP = items.SRP; existingItems.TargetPerUnitIncentive = items.TargetPerUnitIncentive; existingItems.TargetQty = items.TargetQty; dbContext.Entry(existingItems).State = EntityState.Modified; } else { if (items.PK_MstrItems == null) items.PK_MstrItems = Guid.NewGuid(); dbContext.Entry(items).State = EntityState.Added; } dbContext.SaveChanges(); return items; } }
public AppUsers SaveAppUser(AppUsers user) { using (IMsDBContext dbContext = new IMsDBContext()) { var existinguser = (from c in dbContext.AppUsers where c.PK_appUsers == user.PK_appUsers select c).FirstOrDefault(); if (existinguser != null) { existinguser.IsActive = user.IsActive; existinguser.IsAdmin = user.IsAdmin; existinguser.UserCode = user.UserCode; existinguser.UserName = user.UserName; existinguser.UserPassword = user.UserPassword; existinguser.ExpiryDate = user.ExpiryDate; dbContext.Entry(existinguser).State = EntityState.Modified; } else { if (user.PK_appUsers == null) user.PK_appUsers = Guid.NewGuid(); dbContext.Entry(user).State = EntityState.Added; } dbContext.SaveChanges(); return user; } }
public MstrBranches SaveModule(MstrBranches branch) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingBranch = (from c in dbContext.MstrBranches where c.PK_MstrBranches == branch.PK_MstrBranches select c).FirstOrDefault(); if (existingBranch != null) { existingBranch.Address = branch.Address; existingBranch.Area = branch.Area; existingBranch.Branch = branch.Branch; existingBranch.Classification = branch.Classification; existingBranch.FK_MstrDealer = branch.FK_MstrDealer; existingBranch.IsActive = branch.IsActive; existingBranch.NoOfFPS = branch.NoOfFPS; existingBranch.QtrMonth1 = branch.QtrMonth1; existingBranch.QtrMonth2 = branch.QtrMonth2; existingBranch.QtrMonth3 = branch.QtrMonth3; dbContext.Entry(existingBranch).State = EntityState.Modified; } else { if (branch.PK_MstrBranches == null) branch.PK_MstrBranches = Guid.NewGuid(); dbContext.Entry(branch).State = EntityState.Added; } dbContext.SaveChanges(); return branch; } }
public AppUsersModules SaveAppUsersModules(AppUsersModules userModules) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingUserModule = (from c in dbContext.AppUsersModules where c.PK_AppUsersModules == userModules.PK_AppUsersModules select c).FirstOrDefault(); if (existingUserModule != null) { existingUserModule.FK_MstrModules = userModules.FK_MstrModules; existingUserModule.FK_AppUsers = userModules.FK_AppUsers; existingUserModule.AllowToAdd = userModules.AllowToAdd; existingUserModule.AllowToDelete = userModules.AllowToDelete; existingUserModule.AllowToEdit = userModules.AllowToEdit; existingUserModule.AllowToPost = userModules.AllowToPost; existingUserModule.AllowToVoid = userModules.AllowToVoid; dbContext.Entry(existingUserModule).State = EntityState.Modified; } else { if (userModules.PK_AppUsersModules == null) userModules.PK_AppUsersModules = Guid.NewGuid(); dbContext.Entry(userModules).State = EntityState.Added; } dbContext.SaveChanges(); return userModules; } }
public TrxSellOutFromAgency SaveSellOutFromAgency(TrxSellOutFromAgency selloutdatatosave) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingRecord = (from c in dbContext.TrxSellOutFromAgency where c.PK_TrxSellOutFromAgency == selloutdatatosave.PK_TrxSellOutFromAgency select c).FirstOrDefault(); if (existingRecord != null) { existingRecord.area = selloutdatatosave.area; existingRecord.category1 = selloutdatatosave.category1; existingRecord.dealer = selloutdatatosave.dealer; existingRecord.FK_cancelledby = selloutdatatosave.FK_cancelledby; existingRecord.FK_MstrBranches = selloutdatatosave.FK_MstrBranches; existingRecord.FK_MstrFPS = selloutdatatosave.FK_MstrFPS; existingRecord.FK_uploadedby = selloutdatatosave.FK_uploadedby; existingRecord.modelno = selloutdatatosave.modelno; existingRecord.modeofpayment = selloutdatatosave.modeofpayment; existingRecord.month = selloutdatatosave.month; existingRecord.monthday = selloutdatatosave.monthday; existingRecord.offtakeqty = selloutdatatosave.offtakeqty; existingRecord.orprice = selloutdatatosave.orprice; existingRecord.periodcoveredfrom = selloutdatatosave.periodcoveredfrom; existingRecord.periodcoveredto = selloutdatatosave.periodcoveredto; existingRecord.pesoofftake_or = selloutdatatosave.pesoofftake_or; existingRecord.pesoofftake_srp = selloutdatatosave.pesoofftake_srp; existingRecord.product2 = selloutdatatosave.product2; existingRecord.product3 = selloutdatatosave.product3; existingRecord.product4 = selloutdatatosave.product4; existingRecord.productcategory = selloutdatatosave.productcategory; existingRecord.serialno = selloutdatatosave.serialno; existingRecord.srpprice = selloutdatatosave.srpprice; existingRecord.typeofpromotion = selloutdatatosave.typeofpromotion; existingRecord.uploaddate = selloutdatatosave.uploaddate; dbContext.Entry(existingRecord).State = EntityState.Modified; } else { dbContext.Entry(selloutdatatosave).State = EntityState.Added; } dbContext.SaveChanges(); return selloutdatatosave; } }
public MstrDealer SaveDealer(MstrDealer dealer) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingDealer = (from c in dbContext.MstrDealer where c.PK_MstrDealer == dealer.PK_MstrDealer select c).FirstOrDefault(); if (existingDealer != null) { existingDealer.Address = dealer.Address; existingDealer.DealerName = dealer.DealerName; existingDealer.FK_MscIncentiveClass = dealer.FK_MscIncentiveClass; existingDealer.FK_MstrAgency = dealer.FK_MstrAgency; existingDealer.IsActive = dealer.IsActive; dbContext.Entry(existingDealer).State = EntityState.Modified; } else { if (dealer.PK_MstrDealer == null) dealer.PK_MstrDealer = Guid.NewGuid(); dbContext.Entry(dealer).State = EntityState.Added; } dbContext.SaveChanges(); return dealer; } }
public MscSubClassification SaveSubClassification(MscSubClassification subclass) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingSubclass = (from c in dbContext.MscSubClassification where c.PK_MscSubClassification == subclass.PK_MscSubClassification select c).FirstOrDefault(); if (existingSubclass != null) { existingSubclass.SubClassification = subclass.SubClassification; dbContext.Entry(existingSubclass).State = EntityState.Modified; } else { dbContext.Entry(subclass).State = EntityState.Added; } dbContext.SaveChanges(); return subclass; } }
public MstrFPS SaveFPS(MstrFPS fps) { using (IMsDBContext dbContext = new IMsDBContext()) { var existingFPS = (from c in dbContext.MstrFPS where c.PK_MstrFPS == fps.PK_MstrFPS select c).FirstOrDefault(); if (existingFPS != null) { existingFPS.FK_MstrAgency = fps.FK_MstrAgency; existingFPS.FK_MstrBranches = fps.FK_MstrBranches; existingFPS.FK_MstrDealer = fps.FK_MstrDealer; existingFPS.FPSName = fps.FPSName; existingFPS.FPSNumber = fps.FPSNumber; existingFPS.IsActive = fps.IsActive; existingFPS.StoreClassification = fps.StoreClassification; dbContext.Entry(existingFPS).State = EntityState.Modified; } else { if (fps.PK_MstrFPS == null) fps.PK_MstrFPS = Guid.NewGuid(); dbContext.Entry(fps).State = EntityState.Added; } dbContext.SaveChanges(); return fps; } }
public void DeleteFPSByID(Guid id) { using (IMsDBContext dbContext = new IMsDBContext()) { MstrFPS fps = (from c in dbContext.MstrFPS where c.PK_MstrFPS == id select c).FirstOrDefault(); if (fps != null) { dbContext.Entry(fps).State = EntityState.Deleted; dbContext.SaveChanges(); } } }
public void DeleteIncentiveClassByID(Int32 id) { using (IMsDBContext dbContext = new IMsDBContext()) { MscIncentiveClass incentiveClass = (from c in dbContext.MscIncentiveClass where c.PK_MscIncentiveClass == id select c).FirstOrDefault(); if (incentiveClass != null) { dbContext.Entry(incentiveClass).State = EntityState.Deleted; dbContext.SaveChanges(); } } }