public bool Update(ReturnNoteDetailModels model, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { //var itemUpdate = (from tb in cxt.I_Return_Note_Detail // where tb.Id == model.Id // select tb).FirstOrDefault(); //itemUpdate.ReceiptNoteId = model.ReceiptNoteDetailId; //itemUpdate.ReceivedQty = model.ReceivedQty; //itemUpdate.ReturnQty = model.ReturnQty; //itemUpdate.IsActived = model.IsActived; cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Delete(List <string> lstId, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { List <I_Purchase_Order_Detail> listDelete = (from tb in cxt.I_Purchase_Order_Detail where lstId.Contains(tb.Id) select tb).ToList(); if (listDelete != null && listDelete.Count > 0) { cxt.I_Purchase_Order_Detail.RemoveRange(listDelete); cxt.SaveChanges(); } } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Insert(List <DiscountAndMiscReportModels> lstInfo) { var result = true; var info = lstInfo.FirstOrDefault(); using (NuWebContext cxt = new NuWebContext()) { //Check Exist var obj = cxt.R_DiscountAndMiscReport.Where(ww => ww.StoreId == info.StoreId && ww.CreatedDate == info.CreatedDate).FirstOrDefault(); if (obj != null) { NSLog.Logger.Info("Insert Misc data exist"); return(result); } using (var transaction = cxt.Database.BeginTransaction()) { try { List <R_DiscountAndMiscReport> lstInsert = new List <R_DiscountAndMiscReport>(); R_DiscountAndMiscReport itemInsert = null; foreach (var item in lstInfo) { itemInsert = new R_DiscountAndMiscReport(); itemInsert.Id = Guid.NewGuid().ToString(); itemInsert.StoreId = item.StoreId; itemInsert.CreatedDate = item.CreatedDate; itemInsert.DiscountValue = item.DiscountValue; itemInsert.MiscValue = item.MiscValue; itemInsert.Mode = item.Mode; lstInsert.Add(itemInsert); } cxt.R_DiscountAndMiscReport.AddRange(lstInsert); cxt.SaveChanges(); transaction.Commit(); NSLog.Logger.Info("Insert Misc data success", lstInfo); } catch (Exception ex) { NSLog.Logger.Error("Insert Misc data fail", ex); //_logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(lstInfo); //_baseFactory.InsertTrackingLog("R_DiscountAndMiscReport", jsonContent, info.StoreId.ToString(), result); return(result); }
public bool Insert(CountryModels model, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { I_Country item = new I_Country(); item.Id = Guid.NewGuid().ToString(); item.ShortName = model.ShortName; item.FullName = model.FullName; item.ZipCode = model.ZipCode; item.IsActived = model.IsActived; cxt.I_Country.Add(item); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool DeleteListIdRecipeIngredient(string MixtureIngredientId, List <string> listUpdate) { bool result = false; using (var cxt = new NuWebContext()) { try { var listAllId = (from RI in cxt.I_Recipe_Ingredient where RI.MixtureIngredientId.Equals(MixtureIngredientId) && RI.Status != (int)Commons.EStatus.Deleted select RI.Id).ToList(); var listIdDelete = listAllId.Where(a => !(listUpdate.Select(x => x).ToList()).Any(a1 => a1 == a)).ToList(); var listDelete = (from RI in cxt.I_Recipe_Ingredient where listIdDelete.Contains(RI.Id) select RI).ToList(); listDelete.ForEach(x => x.Status = (int)Commons.EStatus.Deleted); cxt.SaveChanges(); result = true; } catch (Exception e) { _logger.Error("GetListIdRecipeIngredient: " + e); } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Update(CountryModels model, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { var itemUpdate = (from tb in cxt.I_Country where tb.Id == model.Id select tb).FirstOrDefault(); itemUpdate.ShortName = model.ShortName; itemUpdate.FullName = model.FullName; itemUpdate.ZipCode = model.ZipCode; itemUpdate.IsActived = model.IsActived; cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Delete(string RoleID, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { var lstResult = (from mp in cxt.G_ModulePermission where mp.RoleID.Equals(RoleID) select mp).ToList(); cxt.G_ModulePermission.RemoveRange(lstResult); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Delete(string RoleId, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { var lstResult = (from tb in cxt.G_RoleOnStore where tb.RoleId.Equals(RoleId) select tb).ToList(); cxt.G_RoleOnStore.RemoveRange(lstResult); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Update(DataEntryDetailModels model, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { var itemUpdate = (from tb in cxt.I_DataEntryDetail where tb.Id == model.Id select tb).FirstOrDefault(); itemUpdate.DataEntryId = model.DataEntryId; itemUpdate.IngredientId = model.IngredientId; //itemUpdate.CloseBal = 0; //model.CloseBal; cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Delete(string Id, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { I_DataEntry itemDelete = (from tb in cxt.I_DataEntry where tb.Id == Id select tb).FirstOrDefault(); if (itemDelete != null) { itemDelete.IsActived = false; } cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Delete(string Id, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { I_Stock_Transfer_Detail itemDelete = (from tb in cxt.I_Stock_Transfer_Detail where tb.Id == Id select tb).FirstOrDefault(); //cxt.I_Stock_Transfer_Detail.Remove(itemDelete); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public void UpdateRecipeIngredient(RecipeIngredientModels model) { using (var cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { var item = cxt.I_Recipe_Ingredient.Where(s => s.Id == model.Id).FirstOrDefault(); if (item != null) { item.UOMId = model.UOMId; item.Usage = model.Usage; item.BaseUsage = model.BaseUsage; item.UpdatedBy = model.UpdatedBy; item.UpdatedDate = DateTime.Now; cxt.SaveChanges(); transaction.Commit(); } } catch (Exception e) { _logger.Error("RecipeProduct_Update: " + e); transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } }
public bool Update(DataEntryModels model, ref string msg) { bool result = true; ResultModels resultModels = new ResultModels(); using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { var itemUpdate = (from tb in cxt.I_DataEntry where tb.Id == model.Id select tb).FirstOrDefault(); itemUpdate.ModifierBy = model.ModifierBy; itemUpdate.ModifierDate = model.ModifierDate; itemUpdate.IsActived = model.IsActived; //Detail //Check item insert var lstDetailId = model.ListItem.Select(ss => ss.Id).ToList(); if (lstDetailId != null && lstDetailId.Count > 0) { var lstDetailUpdate = cxt.I_DataEntryDetail.Where(ww => lstDetailId.Contains(ww.Id)).ToList(); foreach (var item in model.ListItem) { var obj = lstDetailUpdate.Where(ww => ww.Id == item.Id).FirstOrDefault(); if (obj != null) { obj.Damage = item.Damage; obj.Wastage = item.Wast; obj.OrderQty = item.OrderQty; obj.Reasons = item.Reasons; } } } cxt.SaveChanges(); transaction.Commit(); } catch (Exception ex) { _logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } return(result); }
public bool DeleteListIdRecipeProduct(string ItemId, string storeId, List <string> listUpdate, int ProductType) { bool result = false; using (var cxt = new NuWebContext()) { try { if (ProductType == (byte)Commons.EProductType.Dish) { var listAllId = (from RI in cxt.I_Recipe_Item where RI.ItemId.Equals(ItemId) && RI.StoreId.Equals(storeId) && RI.Status != (int)Commons.EStatus.Deleted select RI.Id).ToList(); var listIdDelete = listAllId.Where(a => !(listUpdate.Select(x => x).ToList()).Any(a1 => a1 == a)).ToList(); var listDelete = (from RI in cxt.I_Recipe_Item where listIdDelete.Contains(RI.Id) select RI).ToList(); listDelete.ForEach(x => x.Status = (int)Commons.EStatus.Deleted); cxt.SaveChanges(); } else if (ProductType == (byte)Commons.EProductType.Modifier) { var listAllId = (from RM in cxt.I_Recipe_Modifier where RM.ModifierId.Equals(ItemId) && RM.StoreId.Equals(storeId) && RM.Status != (int)Commons.EStatus.Deleted select RM.Id).ToList(); var listIdDelete = listAllId.Where(a => !(listUpdate.Select(x => x).ToList()).Any(a1 => a1 == a)).ToList(); var listDelete = (from RI in cxt.I_Recipe_Modifier where listIdDelete.Contains(RI.Id) select RI).ToList(); listDelete.ForEach(x => x.Status = (int)Commons.EStatus.Deleted); cxt.SaveChanges(); } result = true; } catch (Exception e) { _logger.Error("GetListIdRecipeProduct: " + e); } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Insert(LanguageModels info) { bool result = false; using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { var isExsit = cxt.G_Language.Any(x => x.Symbol.ToLower().Equals(info.Symbol.ToLower())); if (isExsit) { return(result); } G_Language item = new G_Language(); item.Id = Guid.NewGuid().ToString(); item.Name = info.Name; item.Symbol = info.Symbol; item.Status = (byte)Commons.EStatus.Actived; item.IsDefault = info.IsDefault; item.CreatedDate = DateTime.Now; item.LastModified = DateTime.Now; item.CreatedUser = info.CreatedUser; item.ModifiedUser = info.ModifiedUser; cxt.G_Language.Add(item); cxt.SaveChanges(); transaction.Commit(); result = true; NSLog.Logger.Info("Insert [Insert Language] data success", info); } catch (Exception ex) { NSLog.Logger.Error("Insert [Insert Language] data fail", ex); //_logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(info); //_baseFactory.InsertTrackingLog("G_POSAPIMerchantConfig", jsonContent, info.NuPOSInstance, result); return(result); }
public bool Insert(List <TaxModels> lstInfo) { bool result = true; var info = lstInfo.FirstOrDefault(); using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { List <G_Tax> lstInsert = new List <G_Tax>(); G_Tax itemInsert = null; foreach (var item in lstInfo) { itemInsert = new G_Tax(); itemInsert.Id = Guid.NewGuid().ToString(); itemInsert.StoreId = item.StoreId; itemInsert.Name = item.Name; itemInsert.TaxType = item.TaxType; itemInsert.Percent = item.Percent; itemInsert.IsActive = item.IsActive; itemInsert.DateCreated = item.DateCreated; itemInsert.UserCreated = item.UserCreated; lstInsert.Add(itemInsert); } cxt.G_Tax.AddRange(lstInsert); cxt.SaveChanges(); transaction.Commit(); NSLog.Logger.Info("Insert Tax data success", lstInfo); } catch (Exception ex) { NSLog.Logger.Error("Insert Tax data fail", ex); //_logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(lstInfo); //_baseFactory.InsertTrackingLog("G_Tax", jsonContent, info.StoreId.ToString(), result); return(result); }
/*Employee*/ public bool InsertEmployee(EmployeeConfigApiModels info) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { G_POSEmployeeConfig itemInsert = null; itemInsert = new G_POSEmployeeConfig(); if (string.IsNullOrEmpty(info.Id)) { itemInsert.Id = Guid.NewGuid().ToString(); } else { itemInsert.Id = info.Id; } itemInsert.POSAPIMerchantConfigId = info.POSAPIMerchantConfigId; itemInsert.UserName = info.UserName; itemInsert.Password = CommonHelper.GetSHA512(info.Password); itemInsert.CreatedDate = DateTime.Now; itemInsert.IsActived = true; cxt.G_POSEmployeeConfig.Add(itemInsert); cxt.SaveChanges(); transaction.Commit(); NSLog.Logger.Info("Insert [Insert Pos Api Employee Config] data success", info); } catch (Exception ex) { NSLog.Logger.Error("Insert [Insert Pos Api Employee Config] data fail", ex); //_logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(info); //_baseFactory.InsertTrackingLog("G_POSEmployeeConfig", jsonContent, info.POSAPIMerchantConfigId, result); return(result); }
public bool Insert(List <DateOfWeeksModels> lstInfo) { bool result = true; var info = lstInfo.FirstOrDefault(); using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { List <G_DateOfWeeks> lstInsert = new List <G_DateOfWeeks>(); G_DateOfWeeks itemInsert = null; foreach (var item in lstInfo) { itemInsert = new G_DateOfWeeks(); itemInsert.Id = Guid.NewGuid().ToString(); itemInsert.DayNumber = item.DayNumber; itemInsert.DayName = item.DayName; itemInsert.CreatedDate = item.CreatedDate; itemInsert.CreatedUser = item.CreatedUser; itemInsert.LastUserModified = item.LastUserModified; itemInsert.LastDateModified = item.LastDateModified; lstInsert.Add(itemInsert); } cxt.G_DateOfWeeks.AddRange(lstInsert); cxt.SaveChanges(); transaction.Commit(); } catch (Exception ex) { _logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(lstInfo); //_baseFactory.InsertTrackingLog("G_DateOfWeeks", jsonContent, "DateOfWeeksId", result); return(result); }
public bool Delete(string Id, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { var isExist = (from mp in cxt.G_ModulePermission from ro in cxt.G_RoleOrganization from ros in cxt.G_RoleOnStore from ur in cxt.G_UserRole where mp.RoleID.Equals(ro.Id) && ros.RoleId.Equals(ro.Id) && ur.RoleID.Equals(ro.Id) && ro.Id.Equals(Id) select new { mp, ro, ros, ur }).FirstOrDefault(); if (isExist != null) { result = false; msg = "This role is already in use and unable to be deleted."; } else { string msgChild = ""; _MPFactory.Delete(Id, ref msgChild); _RoSfactory.Delete(Id, ref msgChild); G_RoleOrganization itemDelete = (from tb in cxt.G_RoleOrganization where tb.Id == Id select tb).FirstOrDefault(); cxt.G_RoleOrganization.Remove(itemDelete); cxt.SaveChanges(); //========= } } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Update(UnitOfMeasureModel model, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { var itemExsit = cxt.I_UnitOfMeasure.Where(x => x.Code.ToLower().Equals(model.Code.ToLower()) && x.Status != (int)Commons.EStatus.Deleted && x.OrganizationId == model.OrganizationId).FirstOrDefault(); if (itemExsit != null) { if (!itemExsit.Id.Equals(model.Id)) { msg = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("UOM Code") + " [" + model.Code + "] " + _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("is duplicated"); return(false); } } if (string.IsNullOrEmpty(model.Name)) { model.Name = model.Code; } var itemUpdate = (from tb in cxt.I_UnitOfMeasure where tb.Id == model.Id select tb).FirstOrDefault(); itemUpdate.Code = model.Code; itemUpdate.Name = model.Name; itemUpdate.IsActive = model.IsActive; itemUpdate.UpdatedBy = model.UpdatedBy; itemUpdate.UpdatedDate = model.UpdatedDate; itemUpdate.Description = model.Description; cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public NuWebContext AddToContext(NuWebContext context, BaseEntity entity, int count, int commitCount, bool recreateContext) { context.Entry(entity).State = EntityState.Added; if (count % commitCount == 0) { context.SaveChanges(); if (recreateContext) { context.Dispose(); context = new NuWebContext(); context.Configuration.AutoDetectChangesEnabled = false; } } return(context); }
public bool Insert(List <UserModels> lstInfo) { bool result = true; var info = lstInfo.FirstOrDefault(); using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { List <G_User> lstInsert = new List <G_User>(); G_User itemInsert = null; foreach (var item in lstInfo) { itemInsert = new G_User(); itemInsert.StoreId = item.StoreId; itemInsert.Name = item.Name; itemInsert.Email = item.Email; itemInsert.Password = item.Password; itemInsert.IsActive = item.IsActive; lstInsert.Add(itemInsert); } cxt.G_User.AddRange(lstInsert); cxt.SaveChanges(); transaction.Commit(); } catch (Exception ex) { _logger.Error(ex); result = false; transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } //var jsonContent = JsonConvert.SerializeObject(lstInfo); //_baseFactory.InsertTrackingLog("G_User", jsonContent, info.StoreId.ToString(), result); return(result); }
public bool Delete(string Id, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { //if (IsCanDelete(Id)) { I_Work_Order itemDelete = (from tb in cxt.I_Work_Order where tb.Id == Id select tb).FirstOrDefault(); if (itemDelete != null) { itemDelete.Status = (int)Commons.EStatus.Deleted; var listWOD = (from wod in cxt.I_Work_Order_Detail where wod.WorkOrderId.Equals(itemDelete.Id) select wod).ToList(); listWOD.ForEach(x => x.Status = (int)Commons.EStatus.Deleted); cxt.SaveChanges(); } } //else //{ // msg = "This Work Order has been in used. Can't Delete"; // result = false; //} } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Insert(List <IngredientUOMModels> models, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { List <I_Ingredient_UOM> listInsert = new List <I_Ingredient_UOM>(); I_Ingredient_UOM item = null; foreach (var model in models) { item = new I_Ingredient_UOM(); item.Id = Guid.NewGuid().ToString(); item.IngredientId = model.IngredientId; item.UOMId = model.UOMId; item.BaseUOM = model.BaseUOM; item.ReceivingQty = model.ReceivingQty; item.CreatedBy = model.CreatedBy; item.CreatedDate = model.CreatedDate; item.UpdatedBy = model.UpdatedBy; item.UpdatedDate = model.UpdatedDate; item.IsActived = model.IsActived; listInsert.Add(item); } cxt.I_Ingredient_UOM.AddRange(listInsert); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public void InsertRecipeIngredient(RecipeIngredientModels model, ref string Id) { using (NuWebContext cxt = new NuWebContext()) { using (var transaction = cxt.Database.BeginTransaction()) { try { I_Recipe_Ingredient itemInsert = new I_Recipe_Ingredient(); itemInsert.Id = Guid.NewGuid().ToString(); itemInsert.IngredientId = model.IngredientId; itemInsert.MixtureIngredientId = model.MixtureIngredientId; itemInsert.UOMId = model.UOMId; itemInsert.Usage = model.Usage; itemInsert.Status = (byte)Commons.EStatus.Actived; itemInsert.BaseUsage = model.BaseUsage; itemInsert.CreatedBy = model.CreatedBy; itemInsert.CreatedDate = model.CreatedDate; itemInsert.UpdatedBy = model.UpdatedBy; itemInsert.UpdatedDate = model.UpdatedDate; cxt.I_Recipe_Ingredient.Add(itemInsert); cxt.SaveChanges(); transaction.Commit(); Id = itemInsert.Id; } catch (Exception e) { _logger.Error("RecipeProduct_Insert: " + e); transaction.Rollback(); } finally { if (cxt != null) { cxt.Dispose(); } } } } }
public bool Insert(List <ReceiptPurchaseOrderModels> models, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { List <I_Receipt_Purchase_Order> listInsert = new List <I_Receipt_Purchase_Order>(); I_Receipt_Purchase_Order item = null; foreach (var model in models) { item = new I_Receipt_Purchase_Order(); item.Id = Guid.NewGuid().ToString(); item.ReceiptNoteId = model.ReceiptNoteId; item.PurchaseOrderId = model.PurchaseOrderId; item.CreatedBy = model.CreatedBy; item.CreatedDate = model.CreatedDate; item.ModifierBy = model.ModifierBy; item.ModifierDate = model.ModifierDate; item.IsActived = model.IsActived; listInsert.Add(item); } cxt.I_Receipt_Purchase_Order.AddRange(listInsert); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Insert(List <StockTransferDetailModels> models, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { List <I_Stock_Transfer_Detail> listInsert = new List <I_Stock_Transfer_Detail>(); I_Stock_Transfer_Detail item = null; foreach (var model in models) { item = new I_Stock_Transfer_Detail(); item.Id = Guid.NewGuid().ToString(); item.StockTransferId = model.StockTransferId; item.IngredientId = model.IngredientId; item.RequestQty = model.RequestQty; item.ReceiveQty = model.ReceiveQty; item.IssueQty = model.IssueQty; item.UOMId = model.UOMId; listInsert.Add(item); } cxt.I_Stock_Transfer_Detail.AddRange(listInsert); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Insert(List <PurchaseOrderDetailModels> models, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { List <I_Purchase_Order_Detail> listInsert = new List <I_Purchase_Order_Detail>(); I_Purchase_Order_Detail item = null; foreach (var model in models) { item = new I_Purchase_Order_Detail(); item.Id = Guid.NewGuid().ToString(); item.PurchaseOrderId = model.PurchaseOrderId; item.IngredientId = model.IngredientId; item.Qty = model.Qty; item.UnitPrice = model.UnitPrice; item.Amount = model.Amount; item.ReceiptNoteQty = model.ReceiptNoteQty; item.ReturnReceiptNoteQty = model.ReturnReceiptNoteQty; listInsert.Add(item); } cxt.I_Purchase_Order_Detail.AddRange(listInsert); cxt.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool Delete(string Id, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { // var isExist = (from mp in cxt.G_ModulePermission from ro in cxt.G_RoleOrganization where mp.ModuleID.Equals(Id) && mp.RoleID.Equals(ro.Id) select new { mp, ro }).FirstOrDefault(); if (isExist != null) { result = false; msg = "This module is already in use and unable to be deleted."; } else { G_Module itemDelete = (from tb in cxt.G_Module where tb.Id == Id select tb).FirstOrDefault(); cxt.G_Module.Remove(itemDelete); cxt.SaveChanges(); } } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }
public bool _Update(List <PurchaseOrderDetailModels> models, List <string> listIdDelete, ref string msg) { bool result = true; using (NuWebContext cxt = new NuWebContext()) { try { //Delete Item Delete(listIdDelete, ref msg); //========= List <I_Purchase_Order_Detail> listUpdate = new List <I_Purchase_Order_Detail>(); foreach (var model in models) { var itemUpdate = (from tb in cxt.I_Purchase_Order_Detail where tb.Id == model.Id select tb).FirstOrDefault(); if (itemUpdate != null) { itemUpdate.Qty = model.Qty; itemUpdate.UnitPrice = model.UnitPrice; itemUpdate.Amount = model.Amount; cxt.SaveChanges(); } } } catch (Exception ex) { _logger.Error(ex); result = false; } finally { if (cxt != null) { cxt.Dispose(); } } } return(result); }