public async Task <IHttpActionResult> Remove(int planId) { try { int userId = (await CurrentUser()).Id; Plan plan = _planService.Find(planId); if (plan != null) { if (userId == plan.CreatorId) { bool result = _planService.Delete(plan); if (result) { return(Ok()); } } else { return(Unauthorized()); } } return(BadRequest()); } catch (Exception ex) { _loggingService.Write(GetType().Name, nameof(Remove), ex); return(InternalServerError(ex)); } }
public IActionResult ConfirmRemove(int id) { recipePlanService.DeleteAllWithPlanId(id); planService.Delete(id); return(RedirectToAction("List")); }
public async Task <IActionResult> Delete(int id) { if (await _planService.Delete(id)) { return(NoContent()); } throw new Exception("Error deleting the model no"); }
public IActionResult Delete(Plan plan) { var result = _planService.Delete(plan); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public async Task <IActionResult> Delete(int id) { var model = await _planService.Delete(id); if (model) { await _hubContext.Clients.All.SendAsync("ReceiveCreatePlan"); return(NoContent()); } throw new Exception("Error deleting the model no"); }
public ActionResult Delete(string type, Guid id, DateTime date) { if (type == "Delete") { _iPlanService.Delete(id); } if (type == "Finish") { _iPlanService.Finish(id); } _unitOfWork.Commit(); return(RedirectToAction("Index", new { date })); }
public IActionResult RemovePlan([FromForm] ConfirmRemovePlanViewModel model) { try { _planService.Delete(model.PlanId); } catch { return(RedirectToAction("ConfirmRemovePlan", new { id = model.PlanId })); ; } return(RedirectToAction("List")); }
public async Task <IActionResult> DeleteEmployee(int id) { if (id <= 0) { return(BadRequest()); } var employee = await _planService.GetPlanById(id); if (employee == null) { return(NotFound()); } await _planService.Delete(id); return(Ok()); }
public ActionResult Edit(FormCollection item) { string nativeeditor_status = item[4]; switch (nativeeditor_status) { case "inserted": _iPlanService.Save(null, new Plan { PlanTitle = item[2], StartDate = DateTime.Parse(item[0]), EndDate = DateTime.Parse(item[1]) }); break; } nativeeditor_status = item[5]; switch (nativeeditor_status) { case "deleted": _iPlanService.Delete(Guid.Parse(item[0])); break; case "updated": Plan plan = _iPlanService.GetById(Guid.Parse(item[0])); plan.PlanTitle = item[1]; plan.StartDate = DateTime.Parse(item[2]); plan.EndDate = DateTime.Parse(item[3]); _iPlanService.Save(Guid.Parse(item[0]), plan); break; } _unitOfWork.CommitAsync(); return(null); }
public ActionResult Delete(Guid id) { _iPlanService.Delete(id); _unitOfWork.Commit(); return(Content("True")); }
public async Task <ActionResponse <PlanDto> > Delete([FromBody] SimpleRequestBase request) { return(await planService.Delete(request.Id)); }
public ActionResult Delete(int id) { return(Ok( planService.Delete(id) )); }