public async Task EditTravel(Guid travelId, Travel editedTravel) { Travel travel = await _travelRepository.Get(TravelId.FromGuid(travelId)); travel.Edit(editedTravel); await _travelRepository.Update(travel); }
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)); }
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); } }
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); } }
public async Task Cancel(TravelId travelId) { var travel = await _travelRepository.Get(travelId); travel.Cancel(); }
public async Task <Travel> GetTravel(TravelId travelId) { return(await _travelRepository.Get(travelId)); }