/** * Method responsible for converting a Data model to a Domain model. * Data models are used for communication between the Repository and the Databases (through ORM) * Domain models are used for communication between the Repository and the Domain layer. */ private ScooterDomainModel ToScooterDomainModel(ScooterDataModel scooterDataModel) { return(new ScooterDomainModel( scooterDataModel.Id, scooterDataModel.Latitude, scooterDataModel.Longitude)); }
/** * Create operation * One of the 4 main operations under CRUD * Adds a new Scooter object to the database */ public async Task <ScooterDomainModel> Add(ScooterDomainModel scooterDomainModel) { ScooterDataModel scooterDataModel = ToScooterDataModel(scooterDomainModel); await _databaseContext.AddAsync(scooterDataModel); await _databaseContext.SaveChangesAsync(); return(await Get(scooterDomainModel.Id)); }