public async Task <ActionResult> DeleteAccount()
        {
            PetOwner po = GetOwner();

            var eggs = _eggRepo.GetEggsByPetOwner(po);

            foreach (var egg in eggs)
            {
                _eggRepo.RemoveEgg(egg);
            }

            var listings = _listingRepo.GetListingsByUsers(po);

            foreach (var list in listings)
            {
                _listingRepo.RemoveListing(list);
            }

            if (po.HasImage)
            {
                _imageRepo.RemoveImage(po.Image);
            }

            _poRepo.SaveChanges();
            _poRepo.RemovePO(po);

            var user = await _um.FindByEmailAsync(po.Email);

            await _um.DeleteAsync(user);

            _poRepo.SaveChanges();

            return(Ok());
        }
Example #2
0
        public ActionResult <List <EggDTO> > GetEggsByUser()
        {
            var eggs = _eggRepo.GetEggsByPetOwner(GetOwner());

            return(eggs.Select(e => new EggDTO(e)).ToList());
        }