public async Task <IActionResult> Delete(string serviceCode, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(serviceCode)) { throw new ArgumentNullException(nameof(serviceCode)); } var entity = await Task.Run(() => _service.Get(serviceCode), cancellationToken); if (entity == null) { throw new HttpNotFoundException($"No service definition found for '{serviceCode}'"); } var result = await Task.Run(() => _service.Delete(serviceCode), cancellationToken); if (result) { // remove from cache await DropServiceCacheAsync(serviceCode, cancellationToken); // stop recording await _actionApiService.StopRecordingAsync(serviceCode, cancellationToken); _logger.LogInformation($"Service '{serviceCode}' removed"); return(Ok()); } else { return(StatusCode(500)); } }
public IActionResult Remove(Guid serviceId) { if (User.IsInRole("Admin")) { _serviceService.Delete(serviceId); return(RedirectToAction("GetAll")); } return(RedirectToAction("Login", "Account", "")); }
public JsonResult Delete(int id) { if (_service.CheckDelete(id) == 1) { return(Json(new { result = Constants.UnDelete })); } var f*g = _service.Delete(id); return(Json(f*g == 0 ? new { result = true } : new { result = false })); }
public async override Task Execute(DeleteServiceCommand input, User?user) { var s = await this.service.GetById(input.Id); if (!s.IsOwner(user !)) { throw new AuthorizationException(); } await service.Delete(s); }
public IActionResult Delete(int id) { try { _serviceService.Delete(id); return(Ok()); } catch (System.Exception ex) { return(BadRequest(new { message = ex.Message })); } }
public ActionResult Delete(int id, ServiceMvcViewModel model) { var result = _serviceService.Delete(id); if (!result.Succeeded) { ModelState.AddModelError("", $"Ошибки при удалении услуги:</br>" + $"{string.Join("</br>", result.Errors)}"); return(View(model)); } return(RedirectToAction("Index", new { orgId = model.OwnerId })); }
public HttpResponseMessage Delete(int id) { var entity = _serviceService.GetServiceById(id); if (entity == null) { return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据不存在"))); } if (_serviceService.Delete(entity)) { return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据删除成功"))); } return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据删除失败"))); }
// [Authorize(Roles = "Worker,Admin")] public async Task <IActionResult> Delete(int id) { try { var result = await _serviceService.Delete(id); if (!result.Success) { return(BadRequest(result.Messages)); } } catch (KeyNotFoundException) { Error e = new Error(); e.Message = "Service not found."; return(NotFound(e)); } return(NoContent()); }
public HttpResponseMessage Delete(HttpRequestMessage request, int id) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var oldServie = _serviceService.Delete(id); _serviceService.Save(); var responseData = Mapper.Map <PostOffice.Model.Models.Service, ServiceViewModel>(oldServie); response = request.CreateResponse(HttpStatusCode.Created, responseData); } return response; })); }
public ActionResult Delete(ServiceViewModel viewModel) { try { if (ModelState.IsValid) { var entity = Mapper.Map <ServiceViewModel, Service>(viewModel); _serviceService.Delete(entity); return(RedirectToAction("Index")); } } catch (Exception e) { ModelState.AddModelError("", e.Message); } return(View(viewModel)); }
public IHttpActionResult Deleteservice(int serviceId) { ResponseDataDTO <service> response = new ResponseDataDTO <service>(); try { var serviceDeleted = _serviceservice.Find(serviceId); if (serviceDeleted != null) { _serviceservice.Delete(serviceDeleted); // return response response.Code = HttpCode.OK; response.Message = MessageResponse.SUCCESS; response.Data = null; return(Ok(response)); } else { // return response response.Code = HttpCode.NOT_FOUND; response.Message = MessageResponse.FAIL; response.Data = null; return(Ok(response)); } } catch (Exception ex) { response.Code = HttpCode.INTERNAL_SERVER_ERROR; response.Message = ex.Message; response.Data = null; Console.WriteLine(ex.ToString()); return(Ok(response)); } }
public virtual IActionResult Delete(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageServices)) { return(AccessDeniedView()); } var e = _serviceService.GetById(id); if (e == null) { return(RedirectToAction("List")); } _serviceService.Delete(e); ////activity log //_customerActivityService.InsertActivity("DeleteManufacturer", // string.Format(_localizationService.GetResource("ActivityLog.DeleteManufacturer"), e.Name), e); SuccessNotification(_localizationService.GetResource("Hero.Common.Deleted")); return(RedirectToAction("List")); }
public IActionResult Delete(int id) { _ServiceService.Delete(id); return(Ok(GetResponse("Deleted Successfully"))); }
public async Task <ActionsResult> Remove(int id) { return(await serviceService.Delete(id)); }
public IActionResult Delete(int id) { _service.Delete(id); return(Ok()); }