/// <summary>
 /// Action To Show Search Details
 /// By ID
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult SearchDetails(int id)
 {
     try
     {
         CreateSession();
         SearchInfo info = searchManager.GetSearchInfo();
         info.HotelId       = id;
         info.Hotels        = new Hotel();
         info.Hotels        = hotelManager.FindHotel(id);
         ViewBag.SearchInfo = info;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(View(hotelManager.SearchHotelById(id)));
 }
Exemple #2
0
        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"));
        }