public async Task <IActionResult> UpdateCategory(int categoryId, [FromBody] Category category) { if (category == null) { throw new ArgumentNullException(nameof(category)); } if (categoryId != category.Id) { return(Unauthorized()); } if (!await _repo.CategoryExists(categoryId)) { return(NotFound($"Country {category.Name} does not exist!!")); } if (await _repo.IsCategoryDuplicate(category.Name, categoryId)) { ModelState.AddModelError("", $"Country {category.Name} already exists!"); return(StatusCode(422, ModelState)); } if (!await _work.Update(category)) { ModelState.AddModelError("", $"Something went wrong saving {category.Name}!!"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult Edit(Work modifiedWork) { if (ModelState.IsValid) { _work.Update(modifiedWork); return(RedirectToAction("Index")); } return(View(modifiedWork)); }
private void PollWork() { if (currentWork != null) { currentWork.Update(this); } else if (WorkManager.HasWork) { AssignWork(WorkManager.GetWork()); OnReceivedWorkFromManager(); } }