Exemplo n.º 1
0
        public async Task EditTravel(Guid travelId, Travel editedTravel)
        {
            Travel travel = await _travelRepository.Get(TravelId.FromGuid(travelId));

            travel.Edit(editedTravel);
            await _travelRepository.Update(travel);
        }
Exemplo n.º 2
0
        public static Travel FromDalModel(TravelDal travelDal)
        {
            List <Customer> customers = new List <Customer>();

            if (travelDal.Customers != null && travelDal.Customers.Count > 0)
            {
                foreach (var customer in travelDal.Customers)
                {
                    customers.Add(new Customer(UserId.FromString(customer.Id), customer.FirstName, customer.SurName));
                }
            }

            return(new Travel(TravelId.FromString(travelDal.Id), travelDal.Destination, customers));
        }
Exemplo n.º 3
0
        public async Task <Travel> Get(TravelId id)
        {
            try
            {
                ItemResponse <TravelDal> response = await this._container.ReadItemAsync <TravelDal>(id.ToString(), new PartitionKey(id.ToString()));

                var travelDal = response.Resource;
                return(TravelModelMapper.FromDalModel(travelDal));
            }
            catch (CosmosException ex) when(ex.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public async Task AssignCustomer(TravelId travelId, UserId customerId)
        {
            var travel = await _travelRepository.Get(travelId);

            var customer = await _customerRepository.Get(customerId);

            if (travel == null)
            {
                throw new TravelException("Cannot assign Customer. Travel is null");
            }
            else
            {
                travel.AssignCustomer(customer);
                await _travelRepository.Update(travel);
            }
        }
Exemplo n.º 5
0
        public async Task Cancel(TravelId travelId)
        {
            var travel = await _travelRepository.Get(travelId);

            travel.Cancel();
        }
Exemplo n.º 6
0
 public async Task <Travel> GetTravel(TravelId travelId)
 {
     return(await _travelRepository.Get(travelId));
 }