Пример #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="idCroisiere"></param>
 public Croisieres(string idCroisiere)
 {
     var crs = new Croisieres(idCroisiere);
     Prix = crs.Prix;
     Photo = crs.Photo;
     DateDepart = crs.DateDepart;
 }
Пример #2
0
        public ActionResult Create(CroisieresViewModel cvm, HttpPostedFileBase postedFile)
        {
            if (ModelState.IsValid)
            {
                if (postedFile != null)
                {
                    var filename = Path.GetFileName(postedFile.FileName);
                    if (filename == null)
                        return RedirectToAction("Create");
                    var path = Path.Combine(Server.MapPath("~/Uploads/Bateaux/"), filename);
                    postedFile.SaveAs(path);
                    cvm.Photo = filename;
                }
                Croisieres crs = new Croisieres()
                {
                    IdTheme = cvm.IdTheme,
                    IdDuree = cvm.IdDuree,
                    IdPromo = cvm.IdPromo,
                    IdPort = cvm.IdPort,
                    Prix = cvm.Prix,
                    DateDepart = DateTime.ParseExact(cvm.DateDepart, "dd/MM/yyyy", CultureInfo.InvariantCulture,
                    DateTimeStyles.None),
                    Photo = cvm.Photo,
                    Description = cvm.Description

                };
                db.Croisieres.Add(crs);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.IdDuree = new SelectList(db.Durees, "IdDuree", "NbJours");
            ViewBag.IdPort = new SelectList(db.Ports, "IdPort", "Nom");
            ViewBag.IdPromo = new SelectList(db.Promos, "IdPromo", "Reduction");
            ViewBag.IdTheme = new SelectList(db.Themes, "IdTheme", "Libelle");
            return View();
        }