public OperationResult CreateOrderToGoWithPackage(ServiceDataContracts.OrderToGo orderToGo) { try { log.Debug($"CreateOrderToGoWithPackage"); var otg = Mapper.Map <ServiceDataContracts.OrderToGo, Entities.OrderToGo>(orderToGo); otg.UpdatedDate = DateTime.Now; otg.LastUpdatedSession = orderToGo.LastUpdatedSession; db.OrderToGo.Add(otg); db.SaveChanges(); OrderCustomrInfoService srv = new OrderCustomrInfoService(db); //srv.RecalcCustomerInfo(orderToGo.OrderCustomerId.GetValueOrDefault()); srv.RecalcCustomerAllInfo(); return(new OperationResult { Success = true, CreatedObjectId = otg.Id }); } catch (Exception e) { log.Error($"CreateOrderToGoWithPackage {e.Message}"); return(new OperationResult { Success = false, CreatedObjectId = 0 }); } }
public OperationResult UpdateOrderToGo(ServiceDataContracts.OrderToGo orderToGo) { var order = db.OrderToGo.FirstOrDefault(o => o.Id == orderToGo.Id); if (order == null) { return(new OperationResult { Success = false, ErrorMessage = "OrderFlight Not Found." }); } order.OldId = orderToGo.OldId; order.OrderCustomerId = orderToGo.OrderCustomerId; // order.Comment = orderToGo.Comment; order.DeliveryDate = orderToGo.DeliveryDate; //order.DeliveryPlaceId = orderToGo.DeliveryPlaceId; order.DriverId = orderToGo.DriverId; order.IsSHSent = orderToGo.IsSHSent; order.ExportTime = orderToGo.ExportTime; //order.ExtraCharge = orderToGo.ExtraCharge; order.CommentKitchen = orderToGo.CommentKitchen; order.OrderComment = orderToGo.OrderComment; order.OrderNumber = orderToGo.OrderNumber; order.OrderStatus = (int)orderToGo.OrderStatus; order.PhoneNumber = orderToGo.PhoneNumber; order.ReadyTime = orderToGo.ReadyTime; //order.WhoDeliveredPersonPersonId = orderToGo.WhoDeliveredPersonPersonId; order.MarketingChannelId = orderToGo.MarketingChannelId; order.OrderCustomerId = orderToGo.OrderCustomerId; order.Closed = orderToGo.Closed; order.CreationDate = orderToGo.CreationDate == null ? DateTime.Now : orderToGo.CreationDate.Value; order.CreatedById = orderToGo.CreatedById; order.Summ = orderToGo.Summ; order.DeliveryPrice = orderToGo.DeliveryPrice; order.AddressId = orderToGo.AddressId; order.PreCheckPrinted = orderToGo.PreCheckPrinted; order.NeedPrintFR = orderToGo.NeedPrintFR; order.FRPrinted = orderToGo.FRPrinted; order.NeedPrintPrecheck = orderToGo.NeedPrintPrecheck; order.PaymentId = orderToGo.PaymentId; if (orderToGo.CreationDate != null) { order.CreationDate = orderToGo.CreationDate.Value; } order.DiscountPercent = orderToGo.DiscountPercent; Entities.LogItem logItem = new Entities.LogItem(); if (orderToGo.DishPackages != null) { UpdateDishesForOrder(orderToGo, order, 1); } //order.UpdatedDate = DateTime.Now; order.UpdatedDate = DateTime.Now; order.LastUpdatedSession = order.LastUpdatedSession; db.SaveChanges(); OrderCustomrInfoService srv = new OrderCustomrInfoService(db); srv.RecalcCustomerInfo(orderToGo.OrderCustomerId.GetValueOrDefault()); //srv.RecalcCustomerAllInfo(); return(new OperationResult { Success = true, CreatedObjectId = order.Id }); }