コード例 #1
0
ファイル: FreightAppService.cs プロジェクト: thinhtp/SPMS
        public void CreateFreight(CreateFreightInput input)
        {
            var freight = new Freight {
                FreightCode = input.FreightCode, FreightName = input.FreightName, CreatorUserId = input.CreatorUserId
            };

            _FreightRepository.Insert(freight);
        }
コード例 #2
0
 public async Task CreateOrUpdateFreight(CreateFreightInput input)
 {
     if (input.Id != 0)
     {
         await UpdateFreight(input);
     }
     else
     {
         await CreateFreight(input);
     }
 }
コード例 #3
0
        public async Task CreateFreight(CreateFreightInput input)
        {
            using (_unitOfWorkManager.Current.SetTenantId(_session.TenantId))
            {
                input.TenantId = (int)_session.TenantId;
                var freight = input.MapTo <Freight>();
                var val     = _freightRepository
                              .GetAll().Where(p => p.FreightCode == input.FreightCode || p.FreightName == input.FreightName).FirstOrDefault();

                if (val == null)
                {
                    await _freightRepository.InsertAsync(freight);
                }
                else
                {
                    throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in FreightCode '" + input.FreightCode + "' orFreightName '" + input.FreightName + "'...");
                }
            }
        }