private Guid Create(string name, IEnumerable <ExcursionSightDto> sights) { var newSights = TypeAdapter.Adapt <IEnumerable <ExcursionSight> >(sights); var newExcursion = new Excursion { Id = Guid.NewGuid(), Name = name, ExcursionSights = newSights }; _uow.Excursions.Create(newExcursion); _uow.Save(); return(newExcursion.Id); }
private Guid Create(string name) { var newClient = new Client() { Id = Guid.NewGuid(), Name = name }; _uow.Clients.Create(newClient); _uow.Save(); return(newClient.Id); }
public void Create(TourDto dto) { SetTour(dto); var newTour = TypeAdapter.Adapt <Tour>(dto); newTour.Id = Guid.NewGuid(); if (_uow.Excursions.FindByName(newTour?.Excursion.Name) != null) { AddSnapshotSights(newTour); newTour.Excursion = null; } if (_uow.Clients.FindByName(newTour?.Client.Name) != null) { newTour.Client = null; } _uow.Tours.Create(newTour); _uow.Save(); }
public UserDto Register(UserDto newUser) { var user = _uow.Users.FindByEmail(newUser.EmailAddress); if (user != null) { return(null); } _uow.Users.Create(TypeAdapter.Adapt <User>(newUser)); _uow.Save(); var createdUser = _uow.Users.FindByEmail(newUser.EmailAddress); return(TypeAdapter.Adapt <UserDto>(createdUser)); }