public ActionResult DeleteService(Guid id) { if (id == Guid.Empty) { return(StatusCode(400)); } int result = HeaderValidation.ValidateUserCredentials(Request.Headers[Username], Request.Headers[Password]); if (result == -1) { return(StatusCode(401)); } if (!HeaderValidation.ValidateUserPermissions(result)) { return(StatusCode(403)); } if (!ServiceService.DeleteService(id)) { return(StatusCode(404)); } return(StatusCode(204)); }
public ActionResult DeleteRecord(int id) { var property = _serviceService.GetService(id); if (property != null) { _serviceService.DeleteService(id); } return(RedirectToAction("Index", "Service", new { id = property?.CarrierId })); }
public async Task <IActionResult> DeleteService([Range(1, int.MaxValue)] int serviceId, CancellationToken cancellationToken) { var deleted = await _serviceService.DeleteService(serviceId, cancellationToken); if (deleted) { return(Ok()); } return(NotFound("No Service")); }
public async Task <IActionResult> Delete(int id) { StoredProcedureExecutionResult result = await _serviceService.DeleteService(id); if (result == StoredProcedureExecutionResult.ForeignKeyViolation) { return(BadRequest(HttpStatusCode.Conflict)); } return(Accepted()); }
public ActionResult Delete(int id) { if (_serviceService.DeleteService(id)) { return(Ok()); } else { return(BadRequest()); } }
public ActionResult DeleteService(Guid Id) { var service = _serviceService.GetService(Id); if (service == null) { return(NotFound(401)); } _serviceService.DeleteService(service); _serviceService.Save(); return(Ok(201)); }
public IActionResult DeleteService(int serviceId) { try { serviceService.DeleteService(serviceId); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private void BtnDeleteService_Click(object sender, EventArgs e) { OperationResult operationResult = serviceService.DeleteService(selectedService.ServiceId); if (operationResult.ResultCode == ResultCode.Successful) { SetResult(Result.Ok); this.Finish(); } else { Toast.MakeText(Application.Context, operationResult.Message, ToastLength.Long).Show(); } }
public async Task Delete_Service_Failed(int id) { Setup(); var services = GenerateListOfServices(); _applicationContextMock.Setup(x => x.Services).ReturnsDbSet(services); _testedService = new ServiceService(Logger, _applicationContextMock.Object); var result = (await _testedService.DeleteService(id, CancellationToken.None)); Assert.False(result); }
public void DeleteServiceById_Service_Fail() { // Arrange serviceService = new ServiceService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.Delete <Service>(It.IsAny <int>())).Returns(false).Verifiable(); // Act var response = serviceService.DeleteService(It.IsAny <int>()); // Assert Assert.IsNotNull(response); Assert.IsFalse(response.Result); Assert.IsTrue(response.Notifications.HasErrors()); Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <bool>)); mockRepository.Verify(x => x.Delete <Service>(It.IsAny <int>()), Times.Once); }
public ActionResult DeleteAccount(Guid Id) { try { var result = _accountService.GetAccount(Id); if (result != null) { if (_shipperService.GetShippers(s => s.AccountId == Id).Count() > 0) { var shipper = _shipperService.GetShippers(s => s.AccountId == Id).ToList(); _shipperService.DeleteShipper(shipper.FirstOrDefault()); _shipperService.Save(); } if (_customerService.GetCustomers(c => c.AccountId == Id).Count() > 0) { var customer = _customerService.GetCustomers(s => s.AccountId == Id).ToList(); _customerService.DeleteCustomer(customer.FirstOrDefault()); _customerService.Save(); } if (_storeService.GetStores(s => s.AccountId == Id).Count() > 0) { var store = _storeService.GetStores(s => s.AccountId == Id).ToList(); _storeService.DeleteStore(store.FirstOrDefault()); var listService = _serviceService.GetServices(s => s.StoreId == store[0].Id).ToList(); foreach (var item in listService) { _serviceService.DeleteService(item); } _serviceService.Save(); _storeService.Save(); } _accountService.DeleteAccount(result); _accountService.Save(); return(Ok(201)); } return(NotFound()); } catch (Exception) { return(BadRequest()); } }
public async Task <IActionResult> DeleteService(string serviceId) { var result = await _serviceService.DeleteService(serviceId); if (result) { var isCache = _redisCacheRepository.isExist(Constants.KeyRedis.SERVICES); if (!isCache) { _redisCacheRepository.Delete(Constants.KeyRedis.SERVICES); } var listServices = await _serviceService.GetServices(); _redisCacheRepository.Add(Constants.KeyRedis.SERVICES, listServices); return(NoContent()); } return(BadRequest()); }
public async Task <IActionResult> DeleteService([FromBody] ServiceRequestModel model) { await _serviceService.DeleteService(model); return(Ok()); }
public async Task <IActionResult> DeleteConfirmed(Guid id) { await _serviceService.DeleteService(id); return(RedirectToAction(nameof(Index))); }
public IActionResult DeleteById([FromRoute] int id) { return(Ok(_service.DeleteService(id))); }
public JsonResult DeleteService(int id) { return(Json(_serviceService.DeleteService(id))); }