예제 #1
0
        private async Task <RequestResult <ManufacturerInfoOutput> > CreateAsync(EditManufacturerInfoInput input)
        {
            RequestResult <ManufacturerInfoOutput> rst = new RequestResult <ManufacturerInfoOutput>();

            try
            {
                input.CreationTime  = DateTime.Now;
                input.CreatorUserId = _currentUser.Id;
                var data = ObjectMapper.Map <ManufacturerInfo>(input);
                data = await _manufacturerInfoRepository.InsertAsync(data).ConfigureAwait(false);

                rst.ResultData = ObjectMapper.Map <ManufacturerInfoOutput>(data);
                rst.Flag       = true;
            }
            catch
            {
                rst.Flag = false;
            }
            return(rst);
        }
예제 #2
0
        private async Task <RequestResult <ManufacturerInfoOutput> > UpdateAsync(EditManufacturerInfoInput input)
        {
            RequestResult <ManufacturerInfoOutput> rst = new RequestResult <ManufacturerInfoOutput>();

            try
            {
                var data = await _manufacturerInfoRepository.FirstOrDefaultAsync(u => u.Id == input.Id).ConfigureAwait(false);

                input.CreationTime         = data.CreationTime;
                input.CreatorUserId        = data.CreatorUserId;
                input.LastModificationTime = DateTime.Now;
                input.CreatorUserId        = _currentUser.Id;
                ObjectMapper.Map(input, data);
                rst.Flag       = true;
                rst.ResultData = ObjectMapper.Map <ManufacturerInfoOutput>(data);
            }
            catch
            {
                rst.Flag = false;
            }
            return(rst);
        }
예제 #3
0
        public async Task <RequestResult <ManufacturerInfoOutput> > CreateOrUpdateAsync(EditManufacturerInfoInput input)
        {
            if (input == null)
            {
                return(null);
            }
            RequestResult <ManufacturerInfoOutput> rst;

            if (_currentUser == null)
            {
                _currentUser = base.GetCurrentUser();
            }
            if (input.Id != null)
            {
                rst = await this.UpdateAsync(input).ConfigureAwait(false);
            }
            else
            {
                rst = await this.CreateAsync(input).ConfigureAwait(false);
            }
            return(rst);
        }