Ejemplo n.º 1
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.RecipientId == userId)
            {
                messageFromRepo.RecipientDeleted = true;
            }

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

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

            throw new Exception("Error deleting the message");
        }
Ejemplo n.º 2
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 cannot delete your 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 the photo"));
        }
Ejemplo n.º 3
0
        protected override void onDeleteExecute()
        {
            var result = MessageDialogeService.ShowOkCancelDialog($"Do you really want to delete it{Meeting.Title} ", "Warning");

            if (result == MessageDialogResult.Ok)
            {
                _meetingRepository.Delete(Meeting.Model);
                _meetingRepository.SaveAsync();
                RaiseDetailDeletedEvent(Meeting.Id);
            }
        }
        protected override async void OnDeleteExecute()
        {
            var result = await MessageDialogService.ShowOkCandelDialogAsync("Отменить внесенные изменения?", "Впорос");

            if (result == MessageDialogResult.OK)
            {
                _meetingRepository.Delete(Meeting.Model);
                await _meetingRepository.SaveAsync();

                RaiseDetailDeletedEvent(Meeting.Id);
            }
        }
Ejemplo n.º 5
0
        public ConfirmationResponse Execute(AuthorizedIdRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var meeting = _meetingRepository.Read(request.Id);

            _meetingRepository.Delete(meeting.Id);

            return(new ConfirmationResponse($"Meeting {meeting.Name} successfully deleted.")
            {
                Id = meeting.Id,
            });
        }
Ejemplo n.º 6
0
        public IHttpActionResult Delete(int id)
        {
            var existing = repository.GetById(id);

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

            if (existing.UserId != User.Identity.GetUserId())
            {
                return(BadRequest());
            }

            if (repository.Delete(id))
            {
                return(Ok());
            }

            return(NotFound());
        }
Ejemplo n.º 7
0
        public IActionResult Delete([FromBody] int id)
        {
            _repository.Delete(id);

            return(Ok());
        }
Ejemplo n.º 8
0
 public void Delete(int id)
 {
     _meetingRepository.Delete(id);
 }
Ejemplo n.º 9
0
 public async Task Delete(Meeting entity)
 {
     await _meeting.Delete(entity);
 }
 public object Execute(DeleteMeetingCommandMessage commandMessage)
 {
     _meetingRepository.Delete(commandMessage.Meeting);
     return(commandMessage.Meeting);
 }
 public void Delete(int id)
 {
     _repository.Delete(id);
 }
Ejemplo n.º 12
0
 public ActionResult Delete(int meetingid)
 {
     rep.Delete(meetingid);
     return(Ok());
 }