示例#1
0
        public void SetAboutText(About tekst)
        {
            List <About> abouts = aboutrepository.GetAll().ToList();

            foreach (About x in abouts)
            {
                aboutrepository.Delete(x);
            }

            aboutrepository.Insert(tekst);
        }
        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");
        }
        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, true);

            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"));
        }
示例#4
0
 public void DeleteMessage(Guid id)
 {
     try
     {
         var message = messageRepository.IncludeAll().First(x => x.Id == id);
         message.ListOfComments.Clear();
         messageRepository.Delete(message);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
        public async Task <IActionResult> DeleteNavig(Guid id)
        {
            var navig = _context.Navigs.FirstOrDefault(x => x.Id == id);

            // _context.Navigs.Remove(navig);
            // _context.SaveChanges();
            _repo.Delete(navig);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to delete the navig"));
        }
        public async Task <IActionResult> RemoveDepartment(Guid id)
        {
            var regionToRemove = await _depRepo.GetDepartment(id);

            _repo.Delete(regionToRemove);

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



            return(BadRequest());
            //return Ok();
        }
示例#7
0
        public void DeleteNews(Guid id)
        {
            var news = repository.GetById(id);

            repository.Delete(news);
        }
示例#8
0
        public void DeleteLiterature(Guid id)
        {
            var literature = repository.GetById(id);

            repository.Delete(literature);
        }
示例#9
0
        public void DeleteComment(Guid id)
        {
            var comment = commentrepository.GetById(id);

            commentrepository.Delete(comment);
        }
示例#10
0
        public void DeleteEmployee(Guid id)
        {
            var employee = employeeRepository.GetById(id);

            employeeRepository.Delete(employee);
        }
示例#11
0
 public void deleteFile(Attachment myfile)
 {
     attachrepository.Delete(myfile);
 }
示例#12
0
        public void deleteTextAbout(Guid id)
        {
            var a = aboutrepository.GetById(id);

            aboutrepository.Delete(a);
        }
示例#13
0
        public void DeleteLink(Guid id)
        {
            var x = meetingsrepository.GetById(id);

            meetingsrepository.Delete(x);
        }
示例#14
0
        public void deleteDocumentation(Guid id)
        {
            var documentation = documentationrepository.GetById(id);

            documentationrepository.Delete(documentation);
        }
示例#15
0
        public void DeleteLiterature(Guid id)
        {
            var literature = repository.IncludeAll().ToList().FirstOrDefault(x => x.Id == id);

            repository.Delete(literature);
        }