Ejemplo n.º 1
0
        /// <summary>
        /// Delete floor.
        /// </summary>
        /// <param name="id">Floor id.</param>
        /// <param name="userEmail">Current user email.</param>
        /// <returns></returns>
        public async Task <bool> DeleteFloorAsync(Guid id, string userEmail)
        {
            // Get current user id
            var user = await _accountManager.GetAccountInfoAsync(userEmail);

            if (user == null)
            {
                return(false);
            }

            // Get parent location and check user rights
            var floor = await _floorRepository.GetFloorAsync(id, true, false, false);

            if (floor == null || floor.Location.OwnerId != user.Id)
            {
                return(false);
            }

            await _fileStorageService.DeleteFileAsync(ConcatHelper.GetFloorFileName(floor.LocationId, floor.FloorId, floor.IsSvg));

            await _floorRepository.DeleteAsync(floor);

            return(true);
        }