Exemplo n.º 1
0
        private async Task <RequestResult <PowerSupplyLineOutput> > UpdateAsync(EditPowerSupplyLineInput input)
        {
            RequestResult <PowerSupplyLineOutput> rst = new RequestResult <PowerSupplyLineOutput>();

            try
            {
                var data = await _powerSupplyLineRepository.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 <PowerSupplyLineOutput>(data);;
            }
            catch
            {
                rst.Flag = false;
            }
            return(rst);
        }
Exemplo n.º 2
0
        private async Task <RequestResult <PowerSupplyLineOutput> > CreateAsync(EditPowerSupplyLineInput input)
        {
            RequestResult <PowerSupplyLineOutput> rst = new RequestResult <PowerSupplyLineOutput>();

            try
            {
                input.LastModificationTime = DateTime.Now;
                input.LastModifierUserId   = _currentUser.Id;
                var data = ObjectMapper.Map <PowerSupplyLine>(input);

                data = await _powerSupplyLineRepository.InsertAsync(data).ConfigureAwait(false);

                rst.ResultData = ObjectMapper.Map <PowerSupplyLineOutput>(data);
                rst.Flag       = true;
            }
            catch
            {
                rst.Flag = false;
            }

            return(rst);
        }
Exemplo n.º 3
0
        public async Task <RequestResult <PowerSupplyLineOutput> > CreateOrUpdateAsync(EditPowerSupplyLineInput input)
        {
            if (input == null)
            {
                return(null);
            }
            if (_currentUser == null)
            {
                _currentUser = base.GetCurrentUser();
            }
            RequestResult <PowerSupplyLineOutput> rst;

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