Пример #1
0
        public async Task <IActionResult> DeleteAddress(string tenantId, string userId, string contactId, string addressId)
        {
            if (_tenantRepository.GetById(Guid.Parse(tenantId)) == null)
            {
                return(BadRequest("Tenant id is not valid"));
            }
            if (_userRepository.GetById(Guid.Parse(userId)) == null)
            {
                return(BadRequest("User id is not valid"));
            }
            if (_contactRepository.GetById(Guid.Parse(contactId)) == null)
            {
                return(BadRequest("contact id is not valid"));
            }
            if (_addressRepository.GetById(Guid.Parse(addressId)) == null)
            {
                return(BadRequest("address id is not valid"));
            }
            Address addressToDelete = await _addressRepository.FirstOrDefault(addressItem =>
                                                                              addressItem.Id == Guid.Parse(addressId) &&
                                                                              addressItem.ContactID == Guid.Parse(contactId) &&
                                                                              addressItem.Contact.UserId == Guid.Parse(userId)
                                                                              );

            await _addressRepository.Remove(addressToDelete);

            return(Ok("Address deleted successfully"));
        }
Пример #2
0
        public async Task <ActionResult> DeleteUser(string tenantId, string userId)
        {
            if (await _tenantRepository.GetById(Guid.Parse(tenantId)) == null)
            {
                return(BadRequest("Tenant id is not valid"));
            }
            if (await _userRepository.GetById(Guid.Parse(userId)) == null)
            {
                return(BadRequest("User id is not valid"));
            }
            User user = await _userRepository.GetById(Guid.Parse(userId));

            await _userRepository.Remove(user);

            return(Ok("User contact deleted successfully"));
        }
Пример #3
0
        public async Task <ActionResult> DeleteTenant(string tenantId)
        {
            if (tenantId != null)
            {
                if (_tenantRepository.GetById(Guid.Parse(tenantId)) == null)
                {
                    return(NotFound("Tenant id is not valid"));
                }
                Tenant tenantToDelete = await _tenantRepository.FirstOrDefault(tenant => tenant.Id == Guid.Parse(tenantId));

                await _tenantRepository.Remove(tenantToDelete);

                return(Ok(new SuccessResponse {
                    Message = "User deleted successfully"
                }));
            }
            else
            {
                return(BadRequest("Please provide tenant id"));
            }
        }
Пример #4
0
        public async Task <ActionResult> DeleteContact(string tenantId, string userId, string contactId)
        {
            if (_tenantRepository.GetById(Guid.Parse(tenantId)) == null)
            {
                return(BadRequest("Tenant id is not valid"));
            }
            if (_userRepository.GetById(Guid.Parse(userId)) == null)
            {
                return(BadRequest("User id is not valid"));
            }
            if (_contactRepository.GetById(Guid.Parse(contactId)) == null)
            {
                return(BadRequest("contact id is not valid"));
            }

            Contact contact = await _contactRepository.GetById(Guid.Parse(contactId));

            await _contactRepository.Remove(contact);

            return(Ok("Contact Deleted Successfully"));
        }