Ejemplo n.º 1
0
 public ActionResult Edit(Commandant commandant, HttpPostedFileBase ImageFile)
 {
     if (Session["userName"] != null)
     {
         if (ImageFile != null)
         {
             using (var ms = new MemoryStream())
             {
                 ImageFile.InputStream.CopyTo(ms);
                 commandant.Image = ms.ToArray();
             }
             if (ModelState.IsValid)
             {
                 db.Entry(commandant).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             if (ModelState.IsValid)
             {
                 db.Entry(commandant).State = EntityState.Modified;
                 db.Entry(commandant).Property(x => x.Image).IsModified = false;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
         return(View(commandant));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
Ejemplo n.º 2
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["userName"] != null)
     {
         Commandant commandant = db.Commandants.Find(id);
         db.Commandants.Remove(commandant);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
Ejemplo n.º 3
0
 // GET: Commandants/Edit/5
 public ActionResult Edit(int?id)
 {
     if (Session["userName"] != null)
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Commandant commandant = db.Commandants.Find(id);
         if (commandant == null)
         {
             return(HttpNotFound());
         }
         return(View(commandant));
     }
     else
     {
         return(RedirectToAction("Logout", "Admin"));
     }
 }
Ejemplo n.º 4
0
        public ActionResult Create(Commandant commandant, HttpPostedFileBase ImageFile)
        {
            if (Session["userName"] != null)
            {
                using (var ms = new MemoryStream())
                {
                    ImageFile.InputStream.CopyTo(ms);
                    commandant.Image = ms.ToArray();
                }
                if (ModelState.IsValid)
                {
                    db.Commandants.Add(commandant);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(commandant));
            }
            else
            {
                return(RedirectToAction("Logout", "Admin"));
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            string nomCommandantVaisseau = "";
            bool   finProgramme          = false;

            Console.WriteLine("Bonjour Commandant ... Attendez, quel est votre nom !?");
            nomCommandantVaisseau = Convert.ToString(Console.ReadLine());

            Commandant commandantVaisseau = new Commandant(nomCommandantVaisseau);

            while (finProgramme == false)
            {
                Console.Clear();

                AfficherMenu();
                int choixmenu = Convert.ToInt32(Console.ReadLine());


                switch (choixmenu)
                {
                case 1: AfficherCaracteristique(ref commandantVaisseau.tabVaisseau); break;

                case 2: AfficherSiLegendaireExiste(ref commandantVaisseau.tabVaisseau); break;

                case 3: AfficherPlusAttaque(ref commandantVaisseau.tabVaisseau);  break;

                case 4: AfficherMoyennePrix(ref commandantVaisseau.tabVaisseau);  break;

                case 5: finProgramme = true; break;

                default: Console.WriteLine("Prenez une option dans les choix proposer"); break;
                }
            }

            Console.ReadKey();
        }