Example #1
0
        public async Task <IActionResult> PostBowType([FromBody] BowType bowType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.BowType.Add(bowType);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (BowTypeExists(bowType.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetBowType", new { id = bowType.Id }, bowType));
        }
Example #2
0
        public async Task <IActionResult> PutBowType([FromRoute] int id, [FromBody] BowType bowType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(bowType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BowTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BowType bowType = db.BowTypes.Find(id);

            db.BowTypes.Remove(bowType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Name")] BowType bowType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bowType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bowType));
 }
        public ActionResult Create([Bind(Include = "Name")] BowType bowType)
        {
            if (ModelState.IsValid)
            {
                db.BowTypes.Add(bowType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bowType));
        }
        // GET: BackOffice/BowTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BowType bowType = db.BowTypes.Find(id);

            if (bowType == null)
            {
                return(HttpNotFound());
            }
            return(View(bowType));
        }