コード例 #1
0
        // PUT: api/Groups/5
        public async Task<IHttpActionResult> PutGroup(int id, Group group)
        {
            var groupFromPersist = _context.Groups.FirstOrDefault(item => item.Id == id);

            if (groupFromPersist == null)
                return NotFound();

            groupFromPersist.Name = group.Name;
            groupFromPersist.TeacherId = group.TeacherId;

            return Ok();
        }
コード例 #2
0
        public async Task<IHttpActionResult> PostGroup(Group group)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            group.Id = IdGenerator.Instanse.GetId<Group>();
            _context.Groups.Add(group);

            return CreatedAtRoute("DefaultApi", new { id = group.Id }, group);
        }