public IHttpActionResult PutLocation(int id, Location location) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != location.LocationId) { return(BadRequest()); } db.Entry(location).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
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 ActionResult Edit(int id, DokumentFakture dokument) { try { // TODO: Add update logic here using (LocalDBEntities dbEntity = new LocalDBEntities()) { string idStr = id.ToString(); dbEntity.Entry(dokument).State = System.Data.EntityState.Modified; dbEntity.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <ActionResult> Edit([Bind(Include = "SourceId,Url,Description")] Source source) { if (!string.IsNullOrEmpty(source.Url)) { try { WebClient wclient = new WebClient(); string newsData = wclient.DownloadString(source.Url); XDocument xml = XDocument.Parse(newsData); if (ModelState.IsValid) { db.Entry(source).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } catch { } } return(View(source)); }