Пример #1
0
        public ActionResult Create([Bind(Include = "ID,title,descr,ad,rating,price")] Club club, HttpPostedFileBase image1)
        {
            if (ModelState.IsValid)
            {
                club.img = new byte[image1.ContentLength];
                image1.InputStream.Read(club.img, 0, image1.ContentLength);
                db.Clubs.Add(club);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(club));
        }
Пример #2
0
        public IHttpActionResult Post(User tb)
        {
            coachEntities db = new coachEntities();


            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            db.Users.Add(tb);
            db.SaveChanges();
            return(CreatedAtRoute("DefaultApi", new
            {
                id = tb.ID
            }, tb));
        }