public string Delete(int id) { try { IEnumerable <int> listOfIds = _salonManager.GetIds(); List <OrderEntity> listOfOrders = (List <OrderEntity>)_orderManager.GetList(); if (listOfOrders.Any(c => c.CustomerId == id)) { return($"Customer can't be deleted because there are orders with this customer"); } if (listOfIds.Contains(id)) { _salonManager.Delete(id); return($"Customer with id {id} deleted"); } else { throw new Exception($"Customer with id {id} doesen't found"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public ResultModel <Salon> SalonDelete(Salon model) { int id = model.SalonID; _salonRepository.Delete(id); return(new ResultModel <Salon> { Errors = null, IsValid = true, Message = "Silme Başarılı" }); }
public async Task <ActionResult> Delete(int id) { try { var result = await _repository.GetSalonByIdAsync(id); if (result == null) { return(NotFound()); } _repository.Delete(result); _repository.SaveChangesAsync(); return(Ok("The salon was delete")); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public string Delete(int id) { try { IEnumerable <int> listOfIds = _orderManager.GetIds(); if (listOfIds.Contains(id)) { _orderManager.Delete(id); return($"Order with id {id} deleted"); } else { throw new Exception($"Order with id {id} doesen't found"); } } catch (Exception ex) { throw new Exception(ex.Message); } }