コード例 #1
0
        public IHttpActionResult Update(int id, TeamDto teamDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var teamInDb = _context.Teams.SingleOrDefault(c => c.Id == id);

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

            _factory.MapFromDtoToTeam(teamDto, teamInDb);

            _context.SaveChanges();

            return(Ok(teamDto));
        }
コード例 #2
0
        public ActionResult Save(TeamDto team)
        {
            if (!ModelState.IsValid)
            {
                return(View("TeamForm", team));
            }

            var dbTeam = _context.Teams.SingleOrDefault(t => t.Id == team.Id);

            if (dbTeam == null)
            {
                return(HttpNotFound());
            }

            _factory.MapFromDtoToTeam(team, dbTeam);


            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }