public void CreateFreight(CreateFreightInput input) { var freight = new Freight { FreightCode = input.FreightCode, FreightName = input.FreightName, CreatorUserId = input.CreatorUserId }; _FreightRepository.Insert(freight); }
public async Task CreateOrUpdateFreight(CreateFreightInput input) { if (input.Id != 0) { await UpdateFreight(input); } else { await CreateFreight(input); } }
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 + "'..."); } } }