Ejemplo n.º 1
0
        public async Task <IActionResult> PutIkigai(int id, Ikigai ikigai)
        {
            if (id != ikigai.ID)
            {
                return(BadRequest());
            }

            _context.Entry(ikigai).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IkigaiExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Ikigai> > PostIkigai(Ikigai ikigai)
        {
            ikigai.Positions = new List <Position>();

            _context.Ikigai.Add(ikigai);

            await _context.SaveChangesAsync();

            foreach (var position in Enum.GetNames(typeof(Positions)))
            {
                ikigai.Positions.Add(new Position {
                    position = (Positions)Enum.Parse(typeof(Positions), position), Ikigai_ID = ikigai.ID
                });
            }

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIkigai", new { id = ikigai.ID }, ikigai));
        }