Esempio n. 1
0
        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));
            }
        }
Esempio n. 2
0
        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 }));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public IActionResult Delete(int id)
 {
     try
     {
         _serviceService.Delete(id);
         return(Ok());
     }
     catch (System.Exception ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
Esempio n. 6
0
        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 }));
        }
Esempio n. 7
0
        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, "数据删除失败")));
        }
Esempio n. 8
0
//        [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());
        }
Esempio n. 9
0
 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));
        }
Esempio n. 11
0
        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));
            }
        }
Esempio n. 12
0
        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")));
 }
Esempio n. 14
0
 public async Task <ActionsResult> Remove(int id)
 {
     return(await serviceService.Delete(id));
 }
Esempio n. 15
0
 public IActionResult Delete(int id)
 {
     _service.Delete(id);
     return(Ok());
 }