public OrderToStoreLog SaveLogOrderToStore(OrderToStore orderToStore, string comments, string status, DateTime timestamp, bool bHasToSave = false) { var orderToStoreLog = new OrderToStoreLog { Comments = comments, OrderToStore = orderToStore, Status = status, Timestamp = timestamp }; DbEntities.OrderToStoreLog.Add(orderToStoreLog); if (bHasToSave) { DbEntities.SaveChanges(); } return(orderToStoreLog); }
public OrderToStoreLog SaveLogOrderToStore(long orderId, string comments, string status, DateTime timestamp, bool bHasToSave = false) { var orderToStoreLog = new OrderToStoreLog { Comments = comments, OrderToStoreId = orderId, Status = status, Timestamp = timestamp }; DbEntities.OrderToStoreLog.Add(orderToStoreLog); var orderToStore = new OrderToStore { OrderToStoreId = orderId, LastStatus = status }; DbEntities.OrderToStore.Attach(orderToStore); var entry = DbEntities.Entry(orderToStore); entry.Property(e => e.LastStatus).IsModified = true; if (SettingsData.Constants.TrackConst.OrderStatusEnd.Any(e => e == status)) { orderToStore.EndDatetime = timestamp; entry.Property(e => e.EndDatetime).IsModified = true; } if (bHasToSave) { DbEntities.SaveChanges(); } return(orderToStoreLog); }