public async Task <ActionResult> Delete(int id)
        {
            try
            {
                var dresser = _repository.GetHairdresserById(id);
                if (dresser == null)
                {
                    return(NotFound());
                }

                _repository.Delete(dresser);
                if (await _repository.SaveChangesAsync())
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest("failde to Delete Hairdresser"));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed database"));
            }
        }
예제 #2
0
        public IActionResult DeleteHairdresser()
        {
            Hairdresser hairdresser = _hairdresserRepository.GetByEmail(User.Identity.Name);

            if (hairdresser == null)
            {
                return(NotFound());
            }

            _hairdresserRepository.Delete(hairdresser);
            _hairdresserRepository.SaveChanges();

            return(NoContent());
        }