//DELETE Developer
 public Developer Delete(int id)
 {
     try
     {
         return(DeveloperRepository.Delete(id));
     }
     catch (RepositoryException ex)
     {
         throw new RepositoryException(ex.Message, ex);
     }
 }
        public bool Delete(int id)
        {
            if (_appointmentRepository.FindByQuery(x => x.DeveloperID == id).Any())
            {
                return(false);
            }

            var data = _developerRepository.Get(id);

            _developerRepository.Delete(data);

            return(true);
        }
Beispiel #3
0
        public async Task <IActionResult> Delete([FromRoute] string name)
        {
            if (await _developerRepo.Single(Decode(name)) is Developer developer)
            {
                _developerRepo.Delete(developer);

                await _developerRepo.SaveChangesAsync();

                return(Ok());
            }

            return(NotFound());
        }
Beispiel #4
0
        public async Task <IActionResult> DeletePhoto(int userId, int id)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            var user = await _repo.GetUser(userId);

            if (!user.Photos.Any(p => p.Id == id))
            {
                return(Unauthorized());
            }
            var photoFromRepo = await _repo.GetPhoto(id);

            if (photoFromRepo.IsMain)
            {
                return(BadRequest("You can not delete main photo"));
            }

            if (photoFromRepo.PublicId != null)
            {
                var deleteParams = new DeletionParams(photoFromRepo.PublicId);
                var result       = _cloudinary.Destroy(deleteParams);
                if (result.Result == "ok")
                {
                    _repo.Delete(photoFromRepo);
                }
            }
            if (photoFromRepo.PublicId == null)
            {
                _repo.Delete(photoFromRepo);
            }
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Failed to delete photo"));
        }
Beispiel #5
0
        public async Task Delete(int id)
        {
            try
            {
                var item = await _repository.GetByID(id);

                _repository.Delete(item);
                _repository.Save();
            }
            catch (Exception e)
            {
                _logger.LogError($"There is a problem with delete Developer : {e}");
            }
        }
Beispiel #6
0
        public async Task <IActionResult> DeleteSkill(int id)
        {
            var skillFromRepo = await _repo.GetSkill(id);

            if (skillFromRepo.Id != null)
            {
                _repo.Delete(skillFromRepo);
            }
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Failed to delete Skill"));
        }
        public ActionResult ConfirmDelete(Developer developer, int DeveloperId)//to find the developer to delete
        {
            Developer developerToDelete = context.Find(DeveloperId);

            if (developerToDelete == null)
            {
                return(HttpNotFound());
            }
            else
            {
                context.Delete(DeveloperId);
                context.Commit();                  //refresh cache memory
                return(RedirectToAction("Index")); //redirect to Index page, to view the updated list
            }
        }
Beispiel #8
0
 public IActionResult Delete(int id)
 {
     try
     {
         var data = _developerRepository.Delete(id);
         if (data == 0)
         {
             return(NotFound());
         }
         return(Ok());
     }
     catch (Exception ex)
     {
         return(new StatusCodeResult(500));
     }
 }
Beispiel #9
0
        public async Task <IActionResult> DeleteMessage(int id, int userId)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var messageFromRepo = await _repo.GetMessage(id);

            if (messageFromRepo.SenderId == userId)
            {
                messageFromRepo.SenderDeleted = true;
            }

            if (messageFromRepo.SenderId == userId)
            {
                messageFromRepo.SenderDeleted = true;
            }

            if (messageFromRepo.RecipientId == userId)
            {
                messageFromRepo.RecipientDelete = true;
            }

            if (messageFromRepo.SenderDeleted && messageFromRepo.RecipientDelete)
            {
                _repo.Delete(messageFromRepo);
            }

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception("Error deleting the message");
        }
        public async Task DeleteDeveloper(int id)
        {
            var entity = await _repository.GetByIdAsync(id);

            _repository.Delete(entity);
        }
Beispiel #11
0
 public ActionResult DeveloperDelete(int id)
 {
     developerRepository.Delete(id);
     return(PartialView("_DeveloperList", developerRepository.GetAll()));
 }
Beispiel #12
0
        public bool Delete(int Id)
        {
            bool resultat = _repo.Delete(Id);

            return(resultat);
        }
 public void Delete(int id)
 {
     repo.Delete(id);
 }