public OperationResult UpdateDishPackageFlightOrder(ServiceDataContracts.DishPackageFlightOrder dishPackageFlightOrder)
        {
            log.Info("UpdateDishPackageFlightOrder Id: " + dishPackageFlightOrder.Id);
            //dishPackageFlightOrder.Dish = null;
            //dishPackageFlightOrder.OrderFlight = null;
            var dp = db.DishPackagesFlightOrder.FirstOrDefault(p => p.Id == dishPackageFlightOrder.Id);

            if (dp == null)
            {
                return(new OperationResult {
                    Success = false, ErrorMessage = "DishPackagesFlightOrder Not Found."
                });
            }
            Mapper.Map(dishPackageFlightOrder, dp);
            log.Info($" dishPackageFlightOrder.Deleted: {dishPackageFlightOrder.Deleted} dp {dp.Deleted}");

            /*
             * dp.Amount = dishPackageFlightOrder.Amount;
             * dp.Comment = dishPackageFlightOrder.Comment;
             * dp.DishId = dishPackageFlightOrder.DishId;
             * dp.DishName = dishPackageFlightOrder.DishName;
             * dp.OrderFlightId = dishPackageFlightOrder.OrderFlightId;
             * dp.PassageNumber = dishPackageFlightOrder.PassageNumber;
             * dp.TotalPrice = dishPackageFlightOrder.TotalPrice;
             * dp.PositionInOrder = dishPackageFlightOrder.PositionInOrder;
             *
             * dp.Code = dishPackageFlightOrder.Code;
             */


            db.SaveChanges();
            log.Info("UpdateDishPackageFlightOrder Ok Id: " + dishPackageFlightOrder.Id);

            return(new OperationResult {
                Success = true
            });
        }
        public OperationResult CreateDishPackageFlightOrder(ServiceDataContracts.DishPackageFlightOrder dishPackageFlightOrder)
        {
            try
            {
                log.Debug($"CreateDishPackageFlightOrder {dishPackageFlightOrder.DishId} {dishPackageFlightOrder.Code?.ToString()}");

                if ((dishPackageFlightOrder.DishId == 0) && (dishPackageFlightOrder.Code != null) && (dishPackageFlightOrder.Code != 0))
                {
                    if (db.Dish.Any(a => a.Barcode == dishPackageFlightOrder.Code))
                    {
                        dishPackageFlightOrder.DishId = db.Dish.FirstOrDefault(a => a.Barcode == (long)dishPackageFlightOrder.Code && a.IsTemporary == false).Id;
                    }
                    else
                    {
                        var d = new Entities.Dish()
                        {
                            Barcode          = (long)dishPackageFlightOrder.Code,
                            EnglishName      = "",
                            IsActive         = true,
                            IsAlcohol        = false,
                            IsTemporary      = false,
                            LabelEnglishName = "",
                            LabelRussianName = dishPackageFlightOrder.DishName,
                            Name             = dishPackageFlightOrder.DishName,
                            NeedPrintInMenu  = true,
                            PriceForFlight   = dishPackageFlightOrder.TotalPrice,
                            RussianName      = dishPackageFlightOrder.DishName,
                        };
                        db.Dish.Add(d);
                        db.SaveChanges();
                        dishPackageFlightOrder.DishId = db.Dish.FirstOrDefault(a => a.Barcode == (long)dishPackageFlightOrder.Code && a.IsTemporary == false).Id;
                    }
                }
                log.Debug($"CreateDishPackageFlightOrder dp.DishId : {dishPackageFlightOrder.DishId} ");

                /*
                 * var dp = new Entities.DishPackageFlightOrder();
                 * dp.Amount = dishPackageFlightOrder.Amount;
                 * dp.Comment = dishPackageFlightOrder.Comment;
                 * dp.DishName = dishPackageFlightOrder.DishName;
                 * dp.OrderFlightId = dishPackageFlightOrder.OrderFlightId;
                 * dp.PassageNumber = dishPackageFlightOrder.PassageNumber;
                 * dp.TotalPrice = dishPackageFlightOrder.TotalPrice;
                 * dp.PositionInOrder = dishPackageFlightOrder.PositionInOrder;
                 * dp.Code = dishPackageFlightOrder.Code;
                 */

                var dp = Mapper.Map <ServiceDataContracts.DishPackageFlightOrder, Entities.DishPackageFlightOrder>(dishPackageFlightOrder);

                db.DishPackagesFlightOrder.Add(dp);
                db.SaveChanges();

                return(new OperationResult
                {
                    Success = true,
                    CreatedObjectId = dp.Id
                });
            }
            catch (Exception e)
            {
                log.Error("Error", e);
                return(new OperationResult
                {
                    Success = false,
                    ErrorMessage = e.Message
                });
            }
        }