public OperationResult UpdateDish(ServiceDataContracts.Dish dish) { return(dishService.UpdateDish(dish)); }
public void AddDishToSQL(bool toGo) { //Добавляем блюда, если их нет, синхронизируем имя если они есть var SHDs = GetDishesFromSH(toGo); var SQLDs = AlohaFly.DBProvider.Client.GetDishList().Result; if (SQLDs == null) { return; } foreach (var SHD in SHDs) { _logger.Debug($"GetDish dish rID: {SHD.Rid}, code: {SHD.prCode}, name: {SHD.Name}"); var d = SHD; string s = ""; try { if (SQLDs.Any(a => a.SHId == SHD.Rid)) { _logger.Debug($"AddDishToSQL dish exist {SHD.prCode} {SHD.Name}"); /* * var SQLD = SQLDs.SingleOrDefault(a => a.SHId == SHD.Rid); * if (SHD.ru?.Trim() != "") * { * SQLD.Name = SHD.ru; * } * if (SHD.en?.Trim() != "") * { * SQLD.EnglishName = SHD.en; * //SQLD.LabelEnglishName = SHD.en; * * } * AlohaFly.DBProvider.Client.UpdateDish(SQLD); */ } else { AlohaService.ServiceDataContracts.Dish dd = new AlohaService.ServiceDataContracts.Dish() { Barcode = Convert.ToInt32(SHD.prCode.Replace(".", "")), // Name = (SHD?.ru.Trim() == "") ? SHD.Name : SHD.ru, //EnglishName = SHD.en, SHId = SHD.Rid, IsActive = true, IsTemporary = false, NeedPrintInMenu = true, IsToGo = toGo, }; if (toGo) { dd.PriceForDelivery = SHD.Price / 10000; } else { dd.PriceForFlight = SHD.Price / 10000; } //var bc = if (SHD.ru == null) { dd.Name = SHD.Name; } else { dd.Name = SHD.ru; } if (SHD.en == null) { dd.EnglishName = ""; } else { dd.EnglishName = SHD.en; } //if (dd.EnglishName == null) { dd.EnglishName = ""; } //if (dd.Name == null) { dd.Name = ""; } dd.LabelEnglishName = dd.EnglishName; dd.LabelRussianName = dd.Name; var res = AlohaFly.DBProvider.Client.CreateDish(dd); if (!res.Success) { s = res.ErrorMessage; string ssD = $"{d.Rid};{d.numCode};{d.prCode};{d.Name};{d.ru};{d.en};{d.Price};{d.RidUnit};{d.Unit};{d.Parent}; "; _logger.Error($"Error AlohaFly.DBProvider.Client.CreateDish D: {ssD} {Environment.NewLine} Error: {s}"); } else { _logger.Debug($"AlohaFly.DBProvider.Client.CreateDish AddD: {dd.Barcode} {dd.Name} "); } } } catch (Exception e) { string ssD = $"{d.Rid};{d.numCode};{d.prCode};{d.Name};{d.ru};{d.en};{d.Price};{d.RidUnit};{d.Unit};{d.Parent}; "; _logger.Error($"Error AddDishToSQL D: {ssD} {Environment.NewLine} Error:{e.Message}"); s = e.Message; } } }