public ActionResult Ajouter(Excursion.Data.Hotel hotel, string NomRegion, string NbreEtoiles)
        {
            Excursion.Data.Hotel htl = new Data.Hotel();
            htl.CodeHotel  = hotel.CodeHotel;
            htl.Nom        = hotel.Nom;
            htl.NbrEtoiles = NbreEtoiles;

            //
            try
            {
                HttpPostedFileBase file      = Request.Files[0];
                byte[]             imageSize = new byte[file.ContentLength];
                file.InputStream.Read(imageSize, 0, (int)file.ContentLength);
                //
                string path = System.IO.Path.Combine(Server.MapPath("~/Images/Img/Hotel"), System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(path);
                //
                htl.Photo = file.FileName.Split('\\').Last();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("uploadError", e);
            }
            //

            htl.RegionID = regionRepository.FindOne(x => x.Nom == NomRegion).RegionID;
            hotelRepository.Add(htl);
            hotelRepository.Save();

            #region dropdownlist
            var SysLst = new List <string>();
            var SysQry = from b in regionRepository.FindMany(x => x.Zone.CentreID == SessionData.CurrentUser.CentreID)
                         select b.Nom;
            SysLst.AddRange(SysQry.Distinct());
            ViewBag.regionList = new SelectList(SysLst);

            var SysLst1 = new List <string>();
            SysLst1.Add("1 étoile"); SysLst1.Add("2 étoiles"); SysLst1.Add("3 étoiles"); SysLst1.Add("4 étoiles"); SysLst1.Add("5 étoiles");
            ViewBag.NbreEtoileList = new SelectList(SysLst1);

            #endregion

            return(RedirectToAction("Index", new RouteValueDictionary(
                                        new { controller = "Reservation", action = "Index" })));
        }
Exemple #2
0
 public void Sync(ISyncableData data)
 {
     this._data = (Data.Hotel)data;
 }