Пример #1
0
        public async Task <ActionResult <Models.Team> > PutTeam(long id, Team team)
        {
            bool isUnique = await _context.IsUnique(team.name, id);

            if (!isUnique)
            {
                return(ValidationProblem("Name must be unique"));
            }

            var originalTask = await _context.GetTeam(id);

            team.id   = id;
            team.date = originalTask.date;
            team._id  = originalTask._id;

            await _context.Update(team);

            try
            {
                await _context.SaveChangesAsync();

                return(team);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamExists(id))
                {
                    return(ValidationProblem());
                }
                else
                {
                    throw;
                }
            }
        }