public IHttpActionResult PutInventory([FromBody] DBinventory dBinventory) { InventoryAgent ia = new InventoryAgent(); ia.UpdateInventory(dBinventory.SkuId, dBinventory.SkuName, dBinventory.SubCategoryId); return(Ok()); }
public IHttpActionResult GetSubCategory(int locationId, int departmentId, int categoryId, int subCategoryId) { InventoryAgent ia = new InventoryAgent(); if (ia.SubCategoryExists(locationId, departmentId, categoryId, subCategoryId)) { return(Ok(db.SubCategories.Find(subCategoryId))); } else { return(Ok("subcategory not found")); } }
// GET: api/Locations/{locationId}/Departments/{departmentId}/Categories/{categoryId}/SubCategories public List <SubCategory> GetSubCategories(int locationId, int departmentId, int categoryId) { InventoryAgent ia = new InventoryAgent(); if (ia.CategoryExists(locationId, departmentId, categoryId)) { return(db.SubCategories.ToList().FindAll(sc => sc.CategoryId == categoryId)); } else { return(new List <SubCategory>()); } }
public IHttpActionResult GetDepartment(int locationId, int departmentId) { InventoryAgent ia = new InventoryAgent(); if (ia.DepartmentExists(locationId, departmentId)) { return(Ok(db.Departments.Find(departmentId))); } else { return(Ok("data not found")); } }
// GET: api/Locations/{locationId}/Departments/{departmentId}/Categories public List <Category> GetCategories(int locationId, int departmentId) { InventoryAgent ia = new InventoryAgent(); if (ia.DepartmentExists(locationId, departmentId)) { return(db.Categories.ToList().FindAll(c => c.DepartmentId == departmentId)); } else { return(null); } }
public IHttpActionResult PutSubCategory(int locationId, int departmentId, int categoryId, int subCategoryId, SubCategory subCategory) { if (subCategory.CategoryId != categoryId) { return(Ok("different category values")); } InventoryAgent ia = new InventoryAgent(); if (ia.SubCategoryExists(locationId, departmentId, categoryId, subCategoryId)) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (subCategoryId != subCategory.SubCategoryId) { return(BadRequest()); } db.Entry(subCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SubCategoryExists(subCategoryId)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); } else { return(Ok("data not found")); } }
public IHttpActionResult PutDepartment(int locationId, int departmentId, Department department) { if (department.LocationId != locationId) { return(Ok("different location values")); } InventoryAgent ia = new InventoryAgent(); if (ia.DepartmentExists(locationId, departmentId)) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (departmentId != department.DepartmentId) { return(BadRequest()); } db.Entry(department).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(departmentId)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); } else { return(Ok("data not found")); } }
public IHttpActionResult PostSubCategory(int locationId, int departmentId, int categoryId, SubCategory subCategory) { if (subCategory.CategoryId != categoryId) { return(Ok("different department values")); } InventoryAgent ia = new InventoryAgent(); if (ia.CategoryExists(locationId, departmentId, categoryId)) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SubCategories.Add(subCategory); try { db.SaveChanges(); } catch (DbUpdateException) { if (SubCategoryExists(subCategory.SubCategoryId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = subCategory.SubCategoryId }, subCategory)); } else { return(Ok("data not found")); } }
public IHttpActionResult DeleteSubCategory(int locationId, int departmentId, int categoryId, int subCategoryId) { InventoryAgent ia = new InventoryAgent(); if (ia.SubCategoryExists(locationId, departmentId, categoryId, subCategoryId)) { SubCategory subCategory = db.SubCategories.Find(subCategoryId); if (subCategory == null) { return(NotFound()); } db.SubCategories.Remove(subCategory); db.SaveChanges(); return(Ok(subCategory)); } else { return(Ok("data not found")); } }
public IHttpActionResult DeleteDepartment(int locationId, int departmentId) { InventoryAgent ia = new InventoryAgent(); if (ia.DepartmentExists(locationId, departmentId)) { Department department = db.Departments.Find(departmentId); if (department == null) { return(Ok("department not found")); } db.Departments.Remove(department); db.SaveChanges(); return(Ok(department)); } else { return(Ok("data not found")); } }
public IHttpActionResult GetSkuInfo(int skuId) { InventoryAgent ia = new InventoryAgent(); return(Ok <Inventory>(ia.GetSku(skuId))); }
public IHttpActionResult GetInventoryInfo(int locationId, int departmentId, int categoryId, int subCategoryId) { InventoryAgent ia = new InventoryAgent(); return(Ok <List <Inventory> >(ia.GetInInventories(locationId, departmentId, categoryId, subCategoryId))); }