public async Task <StoreStruct> GetOneAsync(string name) { StoresEntity storesEntity = await context.Stores.Include(c => c.StoreProduct).SingleOrDefaultAsync(s => s.Name == name); if (storesEntity == null) { throw new NoExistInDbException(ExceptionMessages.CannotFindStore()); } return(await CreatStoreStruct(storesEntity)); }
public async Task <ProductStruct> GetOneAsync(string name) { ProductsEntity productEntity = await context.Products.Include(c => c.ProductStore).SingleOrDefaultAsync(s => s.Name == name); if (productEntity == null) { throw new NoExistInDbException(ExceptionMessages.CannotFindStore()); } return(new ProductStruct { Name = productEntity.Name, Description = productEntity.Description, Id = productEntity.Id }); }