Exemplo n.º 1
0
        public IHttpActionResult PutEmoPicture(int id, EmoPicture emoPicture)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != emoPicture.Id)
            {
                return(BadRequest());
            }

            db.Entry(emoPicture).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmoPictureExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public ActionResult Create(CreateSamouraiView CNewS)
        {
            if (ModelState.IsValid)
            {
                if (CNewS.IdArmes != null)
                {
                    Arme arme = db.Armes.FirstOrDefault(i => i.Id == CNewS.IdArmes);
                    CNewS.Samourai.Arme = arme;
                }
                else
                {
                    CNewS.Samourai.Arme = null;
                }
                if (CNewS.IdArtsMartiaux.Count > 0)
                {
                    CNewS.Samourai.ArtMartials = db.ArtMartials.Where(x => CNewS.IdArtsMartiaux.Contains(x.Id)).ToList();
                }
                else
                {
                    CNewS.Samourai.ArtMartials = null;
                }
                CNewS.Samourai.Potentiel = (CNewS.Samourai.Force + CNewS.Samourai.Arme.Degats) * (CNewS.Samourai.ArtMartials.Count + 1);
                db.Samourais.Add(CNewS.Samourai);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(CNewS));
        }
 public async Task <IActionResult> Create([Bind("id,Nome")] Fruit fruit)
 {
     if (ModelState.IsValid)
     {
         _context.Fruit.Add(fruit);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(fruit));
 }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "CategoryID,Title,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "CommentsID,Comment")] Comments comments)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comments);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(comments));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "id,UserID,LOOKRoleID,RoleName,IsRoleActive,LoginName,Password,FirstName,LastName,Gender")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(person));
        }
        public ActionResult Create([Bind(Include = "id,Cost,Year,Make,Model,color")] Car car)
        {
            if (ModelState.IsValid)
            {
                db.Cars.Add(car);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(car));
        }
        public ActionResult Create([Bind(Include = "id,Value,LotSize,Address,City,State,PostalCode")] House house)
        {
            if (ModelState.IsValid)
            {
                db.Houses.Add(house);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(house));
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Id,Nom,Degats")] Arme arme)
        {
            if (ModelState.IsValid)
            {
                db.Armes.Add(arme);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(arme));
        }
        public ActionResult Create([Bind(Include = "ID,Name")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Path")] EmoPicture emoPicture)
        {
            if (ModelState.IsValid)
            {
                db.EmoPictures.Add(emoPicture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(emoPicture));
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "id,Name,admin")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "id,name,x,y")] Markers markers)
        {
            if (ModelState.IsValid)
            {
                db.Markers.Add(markers);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(markers));
        }
Exemplo n.º 14
0
        public ActionResult Create([Bind(Include = "Id,x,y,address,title")] Orange orange)
        {
            if (ModelState.IsValid)
            {
                db.Oranges.Add(orange);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(orange));
        }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "Id,Nom")] ArtMartial artMartial)
        {
            if (ModelState.IsValid)
            {
                db.ArtMartials.Add(artMartial);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(artMartial));
        }
        public ActionResult Create([Bind(Include = "Id,EmoPictureId,X,Y,Width,Height")] EmoFace emoFace)
        {
            if (ModelState.IsValid)
            {
                db.EmoFaces.Add(emoFace);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmoPictureId = new SelectList(db.EmoPictures, "Id", "Name", emoFace.EmoPictureId);
            return(View(emoFace));
        }
Exemplo n.º 17
0
        public ActionResult Create([Bind(Include = "Id,EmotionType,Score,EmoFaceId")] EmoEmotion emoEmotion)
        {
            if (ModelState.IsValid)
            {
                db.EmoEmotions.Add(emoEmotion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmoFaceId = new SelectList(db.EmoFaces, "Id", "Id", emoEmotion.EmoFaceId);
            return(View(emoEmotion));
        }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "ReviewID,Title,Author,Date,Content,CategoryID")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Title", review.CategoryID);
            return(View(review));
        }
Exemplo n.º 19
0
        public IHttpActionResult PostCustomer(Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());

                return(new CustomActionResult <Customer>("Error", Request, HttpStatusCode.NotFound));
            }

            try
            {
                db.Customers.Add(customer);
                db.SaveChanges();
            }
            catch (Exception es)
            {
                Log.Error(es.Message.ToString());
            }

            return(Ok());

            return(new CustomActionResult <Customer>(" OK", Request, HttpStatusCode.OK));
        }
 public void Insert(Seller Seller)
 {
     // Seller.Departments = _context.Departments.First();
     _context.Add(Seller);
     _context.SaveChanges();
 }