public bool WHS_ASNDetail_Update(IEnumerable <WHS_ASNDetail> items, string ModifiedBy) { string WHS_ASNDetail_List = string.Empty; string WHS_ASNDetail_List_Serialized = string.Empty; string WHS_ASNDetail_Items_Serialized = string.Empty; string result = string.Empty; bool flag = true; try { WMS.Models.DBContext model = new DBContext(); foreach (WHS_ASNDetail item in items) { WHS_ASNDetail dbItem = model.DBSet_WHS_ASNDetail.Where(d => d.ID == item.ID).FirstOrDefault(); if (dbItem != null) { WHS_ASNDetail_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.ASN_ID = item.ASN_ID; dbItem.C_System_HoldCode_ID = item.C_System_HoldCode_ID; dbItem.CreatedBy = item.CreatedBy; dbItem.CreatedDate = item.CreatedDate; dbItem.Discrepancy_Qty = item.Discrepancy_Qty; dbItem.Expected_Qty = item.Expected_Qty; dbItem.ID = item.ID; dbItem.IsDeleted = item.IsDeleted; dbItem.Item_ID = item.Item_ID; dbItem.Location_ID = item.Location_ID; dbItem.Lotable_1 = item.Lotable_1; dbItem.Lotable_10 = item.Lotable_10; dbItem.Lotable_11 = item.Lotable_11; dbItem.Lotable_12 = item.Lotable_12; dbItem.Lotable_2 = item.Lotable_2; dbItem.Lotable_3 = item.Lotable_3; dbItem.Lotable_4 = item.Lotable_4; dbItem.Lotable_5 = item.Lotable_5; dbItem.Lotable_6 = item.Lotable_6; dbItem.LPN = item.LPN; dbItem.ModifiedBy = item.ModifiedBy; dbItem.ModifiedDate = item.ModifiedDate; dbItem.Notes = item.Notes; dbItem.Pack_ID = item.Pack_ID; dbItem.Pallet_Label = item.Pallet_Label; dbItem.Receipt_Line_No = item.Receipt_Line_No; dbItem.ReceiptStatus_ID = item.ReceiptStatus_ID; dbItem.Received_Qty = item.Received_Qty; dbItem.UDF_1 = item.UDF_1; dbItem.UDF_2 = item.UDF_2; dbItem.UDF_3 = item.UDF_3; dbItem.UDF_4 = item.UDF_4; dbItem.UDF_5 = item.UDF_5; dbItem.UOM_ID = item.UOM_ID; WHS_ASNDetail_Items_Serialized += Common.SerializeObject(item); Common.SaveChanges(model); WHS_ASNDetail_List_Serialized += Common.SerializeObject(item); } } } catch (Exception ex) { flag = false; result = ex.Message; Common.log.Error(WHS_ASNDetail_Items_Serialized, ex); } finally { if (!string.IsNullOrEmpty(result)) { Common.log.Warn(ModifiedBy + " => " + WHS_ASNDetail_Items_Serialized, new Exception(result)); } Common.log.Info(string.Format("User: {0} - [end] - WHS_ASNDetail_Update: {1} - {2}", ModifiedBy, WHS_ASNDetail_List, WHS_ASNDetail_List_Serialized)); } return(flag); }
public DataSourceResult WHS_ASNDetail_Create(WHS_ASNDetail item, string CreatedBy) { string WHS_ASNDetail_List = string.Empty; string WHS_ASNDetail_List_Serialized = string.Empty; string WHS_ASNDetail_Items_Serialized = string.Empty; string message = string.Empty; List <WHS_ASNDetail> result = new List <WHS_ASNDetail>(); try { WMS.Models.DBContext model = new DBContext(); WHS_ASNDetail dbItem = new WHS_ASNDetail(); item.CreatedBy = item.ModifiedBy = CreatedBy; item.CreatedDate = item.ModifiedDate = Common.getUTCDate(); dbItem.IsSelected = item.IsSelected; dbItem.TagStr = item.TagStr; dbItem.ASN_ID = item.ASN_ID; dbItem.C_System_HoldCode_ID = item.C_System_HoldCode_ID; dbItem.CreatedBy = item.CreatedBy; dbItem.CreatedDate = item.CreatedDate; dbItem.Discrepancy_Qty = item.Discrepancy_Qty; dbItem.Expected_Qty = item.Expected_Qty; dbItem.ID = item.ID; dbItem.IsDeleted = item.IsDeleted; dbItem.Item_ID = item.Item_ID; dbItem.Location_ID = item.Location_ID; dbItem.Lotable_1 = item.Lotable_1; dbItem.Lotable_10 = item.Lotable_10; dbItem.Lotable_11 = item.Lotable_11; dbItem.Lotable_12 = item.Lotable_12; dbItem.Lotable_2 = item.Lotable_2; dbItem.Lotable_3 = item.Lotable_3; dbItem.Lotable_4 = item.Lotable_4; dbItem.Lotable_5 = item.Lotable_5; dbItem.Lotable_6 = item.Lotable_6; dbItem.LPN = item.LPN; dbItem.ModifiedBy = item.ModifiedBy; dbItem.ModifiedDate = item.ModifiedDate; dbItem.Notes = item.Notes; dbItem.Pack_ID = item.Pack_ID; dbItem.Pallet_Label = item.Pallet_Label; dbItem.Receipt_Line_No = item.Receipt_Line_No; dbItem.ReceiptStatus_ID = item.ReceiptStatus_ID; dbItem.Received_Qty = item.Received_Qty; dbItem.UDF_1 = item.UDF_1; dbItem.UDF_2 = item.UDF_2; dbItem.UDF_3 = item.UDF_3; dbItem.UDF_4 = item.UDF_4; dbItem.UDF_5 = item.UDF_5; dbItem.UOM_ID = item.UOM_ID; WHS_ASNDetail_Items_Serialized += Common.SerializeObject(item); model.DBSet_WHS_ASNDetail.Add(dbItem); Common.SaveChanges(model); item.ID = dbItem.ID; WHS_ASNDetail_List += "[" + item.ID + "] "; result.Add(item); WHS_ASNDetail_List_Serialized += Common.SerializeObject(item); } catch (Exception ex) { message = ex.Message; Common.log.Error(WHS_ASNDetail_Items_Serialized, ex); } finally { if (!string.IsNullOrEmpty(message)) { Common.log.Warn(CreatedBy + " => " + WHS_ASNDetail_Items_Serialized, new Exception(message)); } Common.log.Info(string.Format("User: {0} - [end] - WHS_ASNDetail_Create: {1} - {2}", CreatedBy, WHS_ASNDetail_List, WHS_ASNDetail_List_Serialized)); } return(result.ToDataSourceResult(new DataSourceRequest())); }