public IHttpActionResult PutAccessoryCategory(int id, AccessoryCategory accessoryCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != accessoryCategory.ID) { return(BadRequest()); } db.Entry(accessoryCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AccessoryCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetAccessoryCategory(int id) { AccessoryCategory accessoryCategory = db.AccessoryCategories.Find(id); if (accessoryCategory == null) { return(NotFound()); } return(Ok(accessoryCategory)); }
public IHttpActionResult PostAccessoryCategory(AccessoryCategory accessoryCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AccessoryCategories.Add(accessoryCategory); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = accessoryCategory.ID }, accessoryCategory)); }
public IHttpActionResult DeleteAccessoryCategory(int id) { AccessoryCategory accessoryCategory = db.AccessoryCategories.Find(id); if (accessoryCategory == null) { return(NotFound()); } db.AccessoryCategories.Remove(accessoryCategory); db.SaveChanges(); return(Ok(accessoryCategory)); }
public static bool TryToGetSelectedItem(AccessoryCategory category, out Accessory accessory) { foreach (var tagName in Character.Current.SelectedAccessories) { if (!Enum.TryParse(tagName, out AccessoryTag accessoryTag)) { continue; } accessory = accessoryTag.ToAccessory(); if (accessory.category == category) { return(true); } } accessory = null; return(false); }
public IActionResult InsertAccCat([FromBody] DTO.AccessoryCategory accCat) { AccessoryCategoryDAO dao = new AccessoryCategoryDAO(_context); AccessoryCategory dto = new AccessoryCategory { AccCatId = accCat.AccCatId, AccCatName = accCat.AccCatName, PetCatId = accCat.PetCatId }; string msg; if (dao.Insert(dto)) { msg = "Insert accessory category success"; } else { msg = "Insert accessory category failed"; } return(new JsonResult(msg)); }
public bool Delete(AccessoryCategory dto) { _context.AccessoryCategory.Remove(dto); return(_context.SaveChanges() != 0); }
public bool Update(AccessoryCategory dto) { _context.AccessoryCategory.Update(dto); return(_context.SaveChanges() != 0); }
public bool Insert(AccessoryCategory dto) { _context.AccessoryCategory.Add(dto); return(_context.SaveChanges() != 0); }