Example #1
0
        public async Task <IActionResult> PutManager(int id, ManagerInfo managerInfo)
        {
            if (id != managerInfo.ManagerId)
            {
                return(BadRequest());
            }

            Manager manager = managerInfo.CreateModel();

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <ActionResult <ManagerInfo> > PostManager(ManagerInfo managerInfo)
        {
            var manager = managerInfo.CreateModel();

            _context.Managers.Add(manager);
            await _context.SaveChangesAsync();

            managerInfo.ManagerId = manager.Id;
            managerInfo.UserId    = manager.UserId;

            return(CreatedAtAction("PostManager", new { id = managerInfo.ManagerId }, managerInfo));
        }