コード例 #1
0
        public async Task <CoffeeModel> GetCoffeeByIdAsync(int id)
        {
            var CoffeeModel = new CoffeeModel();
            var coffee      = await _context.Set <Coffee>().FindAsync(id);

            return(CoffeeModel.Assign(coffee));
        }
コード例 #2
0
        public async Task <CoffeeModel> CreateCoffeeAsync(CoffeeModel model)
        {
            var coffee = new Coffee();

            coffee.Assign(model);
            await _context.Set <Coffee>().AddAsync(coffee);

            await _context.SaveChangesAsync();

            model.Assign(coffee);
            return(model);
        }