public bool WHS_Zone_Update(IEnumerable <WHS_Zone> items, string ModifiedBy) { string WHS_Zone_List = string.Empty; string WHS_Zone_List_Serialized = string.Empty; string WHS_Zone_Items_Serialized = string.Empty; string result = string.Empty; bool flag = true; try { WMS.Models.DBContext model = new DBContext(); foreach (WHS_Zone item in items) { WHS_Zone dbItem = model.DBSet_WHS_Zone.Where(d => d.ID == item.ID).FirstOrDefault(); if (dbItem != null) { WHS_Zone_List += "[" + item.ID + "] "; item.ModifiedBy = ModifiedBy; item.ModifiedDate = Common.getUTCDate(); if (item.CreatedDate == DateTime.MinValue) { item.CreatedDate = dbItem.CreatedDate; } dbItem.IsSelected = item.IsSelected; dbItem.TagStr = item.TagStr; dbItem.CreatedBy = item.CreatedBy; dbItem.CreatedDate = item.CreatedDate; dbItem.Description = item.Description; dbItem.ID = item.ID; dbItem.IsDeleted = item.IsDeleted; dbItem.Location_ID = item.Location_ID; dbItem.Max_Pallets_per_item = item.Max_Pallets_per_item; dbItem.Max_Pick_Container = item.Max_Pick_Container; dbItem.Max_Pick_Line = item.Max_Pick_Line; dbItem.Maximum_Case_Count = item.Maximum_Case_Count; dbItem.Maximum_Cube = item.Maximum_Cube; dbItem.Maximum_Weight = item.Maximum_Weight; dbItem.ModifiedBy = item.ModifiedBy; dbItem.ModifiedDate = item.ModifiedDate; dbItem.PositiveValidationMethod_ID = item.PositiveValidationMethod_ID; dbItem.Replenishment_MethodDetail_ID = item.Replenishment_MethodDetail_ID; dbItem.ReplenishmentlevelDetail_ID = item.ReplenishmentlevelDetail_ID; dbItem.Zone_Code = item.Zone_Code; WHS_Zone_Items_Serialized += Common.SerializeObject(item); Common.SaveChanges(model); WHS_Zone_List_Serialized += Common.SerializeObject(item); } } } catch (Exception ex) { flag = false; result = ex.Message; Common.log.Error(WHS_Zone_Items_Serialized, ex); } finally { if (!string.IsNullOrEmpty(result)) { Common.log.Warn(ModifiedBy + " => " + WHS_Zone_Items_Serialized, new Exception(result)); } Common.log.Info(string.Format("User: {0} - [end] - WHS_Zone_Update: {1} - {2}", ModifiedBy, WHS_Zone_List, WHS_Zone_List_Serialized)); } return(flag); }
public DataSourceResult WHS_Zone_Create(WHS_Zone item, string CreatedBy) { string WHS_Zone_List = string.Empty; string WHS_Zone_List_Serialized = string.Empty; string WHS_Zone_Items_Serialized = string.Empty; string message = string.Empty; List <WHS_Zone> result = new List <WHS_Zone>(); try { WMS.Models.DBContext model = new DBContext(); WHS_Zone dbItem = new WHS_Zone(); item.CreatedBy = item.ModifiedBy = CreatedBy; item.CreatedDate = item.ModifiedDate = Common.getUTCDate(); dbItem.IsSelected = item.IsSelected; dbItem.TagStr = item.TagStr; dbItem.CreatedBy = item.CreatedBy; dbItem.CreatedDate = item.CreatedDate; dbItem.Description = item.Description; dbItem.ID = item.ID; dbItem.IsDeleted = item.IsDeleted; dbItem.Location_ID = item.Location_ID; dbItem.Max_Pallets_per_item = item.Max_Pallets_per_item; dbItem.Max_Pick_Container = item.Max_Pick_Container; dbItem.Max_Pick_Line = item.Max_Pick_Line; dbItem.Maximum_Case_Count = item.Maximum_Case_Count; dbItem.Maximum_Cube = item.Maximum_Cube; dbItem.Maximum_Weight = item.Maximum_Weight; dbItem.ModifiedBy = item.ModifiedBy; dbItem.ModifiedDate = item.ModifiedDate; dbItem.PositiveValidationMethod_ID = item.PositiveValidationMethod_ID; dbItem.Replenishment_MethodDetail_ID = item.Replenishment_MethodDetail_ID; dbItem.ReplenishmentlevelDetail_ID = item.ReplenishmentlevelDetail_ID; dbItem.Zone_Code = item.Zone_Code; WHS_Zone_Items_Serialized += Common.SerializeObject(item); model.DBSet_WHS_Zone.Add(dbItem); Common.SaveChanges(model); item.ID = dbItem.ID; WHS_Zone_List += "[" + item.ID + "] "; result.Add(item); WHS_Zone_List_Serialized += Common.SerializeObject(item); } catch (Exception ex) { message = ex.Message; Common.log.Error(WHS_Zone_Items_Serialized, ex); } finally { if (!string.IsNullOrEmpty(message)) { Common.log.Warn(CreatedBy + " => " + WHS_Zone_Items_Serialized, new Exception(message)); } Common.log.Info(string.Format("User: {0} - [end] - WHS_Zone_Create: {1} - {2}", CreatedBy, WHS_Zone_List, WHS_Zone_List_Serialized)); } return(result.ToDataSourceResult(new DataSourceRequest())); }