public IActionResult DeleteService(Guid serviceId, [FromHeader] Guid accountId, [FromHeader] string key) { try { if (!auth.AuthorizeUser(key)) { return(StatusCode(StatusCodes.Status401Unauthorized, "Authorization failed!")); } var service = serviceRepository.GetServiceById(serviceId); if (service.AccountId != accountId) { return(StatusCode(StatusCodes.Status403Forbidden, "Not allowed!")); } if (service == null) { return(StatusCode(StatusCodes.Status404NotFound, "There is no service!")); } serviceRepository.DeleteService(serviceId); serviceRepository.SaveChanges(); return(NoContent()); } catch (Exception ex) { logger.Log(LogLevel.Error, contextAccessor.HttpContext.TraceIdentifier, "", "Delete error", null); return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public async Task <ActionResult> Deleteservice(Guid serviceid) { if (!ModelState.IsValid) { return(BadRequest(new ResponseDto <ServiceDto>() { message = "service Id must be Guid" })); } try { await serviceRepository.DeleteService(serviceid); return(Ok(new ResponseDto <string>() { statusCode = "200" })); } catch (Exception e) { if (e.Message == ErrorMessage.EntityDoesNotExist) { return(BadRequest(new ResponseDto <ServiceDto>() { statusCode = "400", message = ErrorMessage.EntityDoesNotExist })); } //if you get to this point something unusual occured return(StatusCode(500, new ResponseDto <string>() { statusCode = "500" })); } }
public ActionResult Delete(int serviceId) { Service deletedService = repository.DeleteService(serviceId); if (deletedService != null) { TempData["message"] = string.Format("Товар\"{0}\" был удалена", deletedService.Name); } return(RedirectToAction("Index")); }
public IHttpActionResult DeleteService(int id) { var success = serviceRepository.DeleteService(id); if (!success) { return(NotFound()); } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult Delete(int serviceId) { Service deletedService = repository.DeleteService(serviceId); log.Info($"Диагноз {deletedService} удален."); if (deletedService != null) { TempData["message"] = $"{deletedService.Name} был удален"; } return(RedirectToAction("Index")); }
// Опис: Метод кој овозможува отстранување на сервис // Влезни параметри: IServiceRepository serviceRepository, Service service, ILogger logger // Излезни параметри: / public void DeleteService(IServiceRepository serviceRepository, Service service, ILogger logger) { try { serviceRepository.DeleteService(service); } catch (Exception e) { var nameLogerError = "DynamicallySetName"; logger.Error(JsonConvert.SerializeObject(service) + "------------" + e.Message, e, "Direction " + nameLogerError); throw new FaultException(e.Message); } }
public IActionResult Delete(int id) { Service service = _serviceRepository.GetServiceById(id); if (service == null) { return(NotFound()); } _serviceRepository.DeleteService(service); return(RedirectToAction("index")); }
public IActionResult Delete(int serviceId) { List <ShoppingCartItem> shoppingCartItems = _applicationDbContext.ShoppingCartItems.Where(x => x.Service.ServiceId == serviceId).ToList(); foreach (ShoppingCartItem shoppingCart in shoppingCartItems) { _applicationDbContext.ShoppingCartItems.Remove(shoppingCart); } Service deletedService = repository.DeleteService(serviceId); log.Info($"Диагноз {deletedService} удален."); if (deletedService != null) { TempData["message"] = $"{deletedService.Name} был удален"; } return(RedirectToAction("Index")); }
public bool DeleteService(Guid id) { if (id == Guid.Empty) { return(false); } try { return(ServiceRepository.DeleteService(id)); } catch (Exception ex) { Logger.LogFile($"Error deleting a Service: {ex.Message}"); return(false); } }
public async Task<StoredProcedureExecutionResult> DeleteService(int id) { return Mapper.Map<StoredProcedureExecutionResult>(await _serviceRepository.DeleteService(id)); }
public bool DeleteService(int ServiceId) { return(_ServiceRepository.DeleteService(ServiceId)); }
public string DeleteService(int?Id) { return(_ServiceRepository.DeleteService(Id)); }
public void DeleteServiceTest() { _serviceRepository.DeleteService(8); }
public string DeleteService(int id) { return(_serviceRepository.DeleteService(id)); }
public void DeleteService(int?id) { _serviceRepository.DeleteService(id); }
public IActionResult DeleteService(Service service) { repository.DeleteService(service); TempData["message"] = $"Услуга с номером {service.ServiceID} была удалена"; return(RedirectToAction(nameof(List))); }
public void DeleteService(int serviceId) { serviceRepository.DeleteService(serviceId); //Deleting service from the database }