コード例 #1
0
        public async Task <ActionResult <Priredi> > GetPriredi(int id)
        {
            Priredi model = await _context.Prirede
                            .Include(x => x.pozoriste)
                            .Include(x => x.propDeoFest)
                            .FirstOrDefaultAsync(i => i.id == id);

            if (model == null)
            {
                return(NotFound());
            }

            return(model);
        }
コード例 #2
0
        public async Task <ActionResult <Priredi> > AddPriredi(Priredi model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Entry(model.propDeoFest).State = EntityState.Unchanged;
            _context.Entry(model.pozoriste).State   = EntityState.Unchanged;

            _context.Prirede.Add(model);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPriredi", new { id = model.id }, model));
        }