DocSas/PropertyService.Domain/ModelView/property/PropertyProvider.cs
/// <summary>
/// delete property as an asynchronous operation.
/// </summary>
/// <param name="propertyId">The property identifier.</param>
/// <param name="userId">The user identifier.</param>
/// <returns>Task&lt;DSCResponse&gt;.</returns>
delete property as an asynchronous operation.
delete property as an asynchronous operation .
public async Task<DSCResponse> DeletePropertyAsync(Guid propertyId, Guid userId)
        {
            var response = new DSCResponse();
            var msg = new Dictionary<string, string>();
            var issuccess = false;
            var management = await _appCommon.GetManagementUserAsync(userId);
            if (management != null)
            {
                var tenants = await  _tenantUnitRepo.GetSingleAsync(x => x.PropertyInformationId == propertyId);
                if (tenants == null)
                {
                    var prop = await _propertyRepo.GetSingleAsync(x => x.Id == propertyId && x.ManagementUserId == management.Id);
                    if (prop != null)
                    {
                        issuccess = await _propertyRepo.DeleteAsync(prop);
                    }
                }
                else
                {
                    msg.Add("CantDeleteProperty", "Property has Tenants, deletion is not allowed");
                }
            }
            response.ErrorMessage = msg;
            response.ResponseData = issuccess;
            return response;
        }
public async Task < DSCResponse > DeletePropertyAsync ( Guid propertyId , Guid userId ) { var response = new DSCResponse ( ) ; var msg = new Dictionary < string , string > ( ) ; var issuccess = false ; var management = await _appCommon . GetManagementUserAsync ( userId ) ; if ( management != null ) { var tenants = await _tenantUnitRepo . GetSingleAsync ( x => x . PropertyInformationId == propertyId ) ; if ( tenants == null ) { var prop = await _propertyRepo . GetSingleAsync ( x => x . Id == propertyId && x . ManagementUserId == management . Id ) ; if ( prop != null ) { issuccess = await _propertyRepo . DeleteAsync ( prop ) ; } } else { msg . Add ( " " , " " ) ; } } response . ErrorMessage = msg ; response . ResponseData = issuccess ; return response ; }
delete property as an asynchronous operation.
delete property as an asynchronous operation .
None
propertyId
Guid
The property identifier.
The property identifier .
userId
Guid
The user identifier.
The user identifier .