public bool ENT_Delivery_Note_Update(IEnumerable <ENT_Delivery_Note> items, string ModifiedBy) { string ENT_Delivery_Note_List = string.Empty; string ENT_Delivery_Note_List_Serialized = string.Empty; string ENT_Delivery_Note_Items_Serialized = string.Empty; string result = string.Empty; bool flag = true; try { WMS.Models.DBContext model = new DBContext(); foreach (ENT_Delivery_Note item in items) { ENT_Delivery_Note dbItem = model.DBSet_ENT_Delivery_Note.Where(d => d.ID == item.ID).FirstOrDefault(); if (dbItem != null) { ENT_Delivery_Note_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.ID = item.ID; dbItem.IsDeleted = item.IsDeleted; dbItem.ModifiedBy = item.ModifiedBy; dbItem.ModifiedDate = item.ModifiedDate; dbItem.Note = item.Note; dbItem.Printed_Date = item.Printed_Date; dbItem.SO_Detail_ID = item.SO_Detail_ID; dbItem.Warehouse_ID = item.Warehouse_ID; ENT_Delivery_Note_Items_Serialized += Common.SerializeObject(item); Common.SaveChanges(model); ENT_Delivery_Note_List_Serialized += Common.SerializeObject(item); } } } catch (Exception ex) { flag = false; result = ex.Message; Common.log.Error(ENT_Delivery_Note_Items_Serialized, ex); } finally { if (!string.IsNullOrEmpty(result)) { Common.log.Warn(ModifiedBy + " => " + ENT_Delivery_Note_Items_Serialized, new Exception(result)); } Common.log.Info(string.Format("User: {0} - [end] - ENT_Delivery_Note_Update: {1} - {2}", ModifiedBy, ENT_Delivery_Note_List, ENT_Delivery_Note_List_Serialized)); } return(flag); }
public DataSourceResult ENT_Delivery_Note_Create(IEnumerable <ENT_Delivery_Note> items, string CreatedBy) { string ENT_Delivery_Note_List = string.Empty; string ENT_Delivery_Note_List_Serialized = string.Empty; string ENT_Delivery_Note_Items_Serialized = string.Empty; string message = string.Empty; List <ENT_Delivery_Note> result = new List <ENT_Delivery_Note>(); try { WMS.Models.DBContext model = new DBContext(); foreach (ENT_Delivery_Note item in items) { ENT_Delivery_Note dbItem = new ENT_Delivery_Note(); 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.ID = item.ID; dbItem.IsDeleted = item.IsDeleted; dbItem.ModifiedBy = item.ModifiedBy; dbItem.ModifiedDate = item.ModifiedDate; dbItem.Note = item.Note; dbItem.Printed_Date = item.Printed_Date; dbItem.SO_Detail_ID = item.SO_Detail_ID; dbItem.Warehouse_ID = item.Warehouse_ID; ENT_Delivery_Note_Items_Serialized += Common.SerializeObject(item); model.DBSet_ENT_Delivery_Note.Add(dbItem); Common.SaveChanges(model); item.ID = dbItem.ID; ENT_Delivery_Note_List += "[" + item.ID + "] "; result.Add(item); ENT_Delivery_Note_List_Serialized += Common.SerializeObject(item); } } catch (Exception ex) { message = ex.Message; Common.log.Error(ENT_Delivery_Note_Items_Serialized, ex); } finally { if (!string.IsNullOrEmpty(message)) { Common.log.Warn(CreatedBy + " => " + ENT_Delivery_Note_Items_Serialized, new Exception(message)); } Common.log.Info(string.Format("User: {0} - [end] - ENT_Delivery_Note_Create: {1} - {2}", CreatedBy, ENT_Delivery_Note_List, ENT_Delivery_Note_List_Serialized)); } return(result.ToDataSourceResult(new DataSourceRequest())); }