Beispiel #1
0
        /// <summary>
        /// Delete a file form server
        /// </summary>
        /// <param name="id">FileEntity Id</param>
        /// <returns></returns>
        public async Task <BaseJsonResult> Delete(long id)
        {
            var serviceModel = new BaseDeleteServiceModel()
            {
                EntityId = id
            };

            var result = await _fileService.Delete(serviceModel);

            if (result.Code == Omi.Base.Properties.Resources.POST_SUCCEEDED)
            {
                _logger.LogInformation($"A file was deleted.");
            }

            return(result);
        }
Beispiel #2
0
        public async Task <BaseJsonResult> Delete(BaseDeleteServiceModel model)
        {
            // TODO: Check role of the User before do anything;

            var fileEntity = await _context.Set <FileEntity>().FindAsync(model.EntityId);

            if (fileEntity == null)
            {
                return(new BaseJsonResult(Omi.Base.Properties.Resources.ENTITY_NOT_FOUND));
            }

            _context.Remove(fileEntity);
            await _context.SaveChangesAsync();

            return(new BaseJsonResult(Omi.Base.Properties.Resources.POST_SUCCEEDED));
        }