Пример #1
0
        public async Task <ActionResult <AttachmentDto> > Put([FromBody] AttachmentEditDto value)
        {
            if (value.Id == Guid.Empty)
            {
                throw new Exception("Unable to edit a Attachment without ID");
            }
            var res = await _service.Save(value);

            return(res);
        }
Пример #2
0
        /// <summary>
        /// 编辑Attachment
        /// </summary>

        protected virtual async Task UpdateAttachmentAsync(AttachmentEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新
            var entity = await _attachmentRepository.GetAsync(input.Id.Value);

            input.MapTo(entity);

            // ObjectMapper.Map(input, entity);
            await _attachmentRepository.UpdateAsync(entity);
        }
Пример #3
0
        public static Attachment ToEntity(this AttachmentEditDto e)
        {
            if (e == null)
            {
                return(null);
            }

            var res = new Attachment();

            res.Id         = e.Id;
            res.Name       = e.Name;
            res.IdResource = e.IdResource;
            res.FullPath   = e.FullPath;
            res.Size       = e.Size;
            return(res);
        }
Пример #4
0
        /// <summary>
        /// 新增Attachment
        /// </summary>

        protected virtual async Task <AttachmentEditDto> CreateAttachmentAsync(AttachmentEditDto input)
        {
            var plan = await _planRepository.GetAsync(input.PlanId);

            if (plan == null)
            {
                throw new EntityNotFoundException();
            }

            var entity = ObjectMapper.Map <Attachment>(input);

            entity = await _attachmentRepository.InsertAsync(entity);

            plan.Attachments.Add(entity);

            return(entity.MapTo <AttachmentEditDto>());
        }
Пример #5
0
        /// <summary>
        /// 导出Attachment为excel表
        /// </summary>
        /// <returns></returns>
        //public async Task<FileDto> GetAttachmentsToExcel(){
        //var users = await UserManager.Users.ToListAsync();
        //var userListDtos = ObjectMapper.Map<List<UserListDto>>(users);
        //await FillRoleNames(userListDtos);
        //return _userListExcelExporter.ExportToFile(userListDtos);
        //}
        /// <summary>
        /// MPA版本才会用到的方法
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <GetAttachmentForEditOutput> GetAttachmentForEdit(NullableIdDto <int> input)
        {
            var output = new GetAttachmentForEditOutput();
            AttachmentEditDto attachmentEditDto;

            if (input.Id.HasValue)
            {
                var entity = await _attachmentRepository.GetAsync(input.Id.Value);

                attachmentEditDto = entity.MapTo <AttachmentEditDto>();

                //attachmentEditDto = ObjectMapper.Map<List <attachmentEditDto>>(entity);
            }
            else
            {
                attachmentEditDto = new AttachmentEditDto();
            }

            output.Attachment = attachmentEditDto;
            return(output);
        }
Пример #6
0
 public void Download(AttachmentEditDto input)
 {
     throw new NotImplementedException();
 }
Пример #7
0
        public void Save(AttachmentEditDto input)
        {
            var item = new Attachment();

            this._attachmentRepository.Insert(input.MapTo(item));
        }
Пример #8
0
        public async Task <ActionResult <AttachmentDto> > Post([FromBody] AttachmentEditDto value)
        {
            var res = await _service.Save(value);

            return(res);
        }
Пример #9
0
 public Task <AttachmentDto> Save(AttachmentEditDto filter)
 {
     throw new NotImplementedException();
 }