Ejemplo n.º 1
0
        public async Task <StoreModel> CreateStoreAsync(StoreModel newStore)
        {
            var storeEntity = mapper.Map <StoreEntity>(newStore);

            repository.CreateStore(storeEntity);
            var res = await repository.SaveChangesAsync();

            if (res)
            {
                return(mapper.Map <StoreModel>(storeEntity));
            }
            throw new Exception("Database Exception");
        }
        public async Task <InstrumentModel> CreateInstrumentAsync(int storeId, InstrumentModel newInstrument)
        {
            await ValidateStoreAsync(storeId);

            newInstrument.StoreId = storeId;
            var instrumentEntity = mapper.Map <InstrumentEntity>(newInstrument);

            repository.CreateInstrument(instrumentEntity);

            var res = await repository.SaveChangesAsync();

            if (res)
            {
                return(mapper.Map <InstrumentModel>(instrumentEntity));
            }
            throw new Exception("Database Exception");
        }