Пример #1
0
        public virtual async Task UpdateMaterielsAsync(MaterielsEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新
            CheckErrors(await CheckMaterielsCodeIsExsit(input.MaterialCode, input.Id.ToString()));
            var entity = await _materielsRepository.GetAsync(input.Id.Value);

            input.MapTo(entity);

            await _materielsRepository.UpdateAsync(entity);
        }
Пример #2
0
        public virtual async Task <MaterielsEditDto> CreateMaterielsAsync(MaterielsEditDto input)
        {
            //TODO:新增前的逻辑判断,是否允许新增
            CheckErrors(await CheckMaterielsCodeIsExsit(input.MaterialCode, string.Empty));

            var entity = input.MapTo <Materiels>();

            entity = await _materielsRepository.InsertAsync(entity);

            return(entity.MapTo <MaterielsEditDto>());
        }
Пример #3
0
        /// <summary>
        /// 通过Id获取物料表信息进行编辑或修改
        /// </summary>
        public async Task <GetMaterielsForEditOutput> GetMaterielsForEditAsync(NullableIdDto <System.Guid> input)
        {
            var output = new GetMaterielsForEditOutput();

            MaterielsEditDto materielsEditDto;

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

                materielsEditDto = entity.MapTo <MaterielsEditDto>();
            }
            else
            {
                materielsEditDto = new MaterielsEditDto();
            }

            output.Materiels = materielsEditDto;
            return(output);
        }