public IActionResult Add(IFormFile Data, string Description, string HotelName, string TownName, string RegionName, int Price) { Tour Tour = new Tour(); Tour.Description = Description; int idregion; try { idregion = _managerregion.FindRegion(RegionName); } catch { _managerregion.Add(RegionName); idregion = _managerregion.FindRegion(RegionName); } int idtown; try { idtown = _managertowns.FindTowns(TownName, idregion); } catch { _managertowns.Add(TownName, idregion); idtown = _managertowns.FindTowns(TownName, idregion); } int idHotel; try { idHotel = _managerhotel.FindHotel(HotelName, idtown); } catch { _managerhotel.Add(HotelName, idtown); idHotel = _managerhotel.FindHotel(HotelName, idtown); } Tour.HotelId = idHotel; Tour.Price = Price; _managertour.Add(Tour); //----------------------------------------------------------------------------- if (Data != null) { byte[] imageData = null; // считываем переданный файл в массив байтов using (var binaryReader = new BinaryReader(Data.OpenReadStream())) { imageData = binaryReader.ReadBytes((int)Data.Length); } // установка массива байтов _managertour.AddImage(imageData, 5); } return(Redirect("/ManageTours")); }