コード例 #1
0
        public ActionResult Create(TeamsVm model)
        {
            if (model is null || string.IsNullOrWhiteSpace(model.Name))
            {
                TempData["error"] = $"You did not fill name. Name is required.";
                return(RedirectToAction("Create"));
            }
            TeamsModel team = new TeamsModel()
            {
                Name = model.Name
            };

            try
            {
                if (!_teamService.Create(team))
                {
                    TempData["error"] = $"Problems with create team (Service error \"Create\").";
                    return(RedirectToAction("Create"));
                }
            }
            catch (Exception e)
            {
                TempData["error"] = $"Problems with saving information to database (services). {e.Message}";
                return(RedirectToAction("Create"));
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult <Team> Create([FromBody] Team newTeam)
 {
     try
     {
         return(Ok(_ts.Create(newTeam)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #3
0
        public ActionResult <Team> Create([FromBody] Team newData)
        {
            try
            {
                newData.CreatorId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

                return(Ok(_ps.Create(newData)));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #4
0
        public ActionResult <TeamsDocument> CreateTeam(TeamsDocument team)
        {
            _teamsService.Create(team);

            return(CreatedAtRoute("GetTeam", new { id = team.Id.ToString() }, team));
        }
コード例 #5
0
        public ActionResult <Team> Create([FromBody] Team team)
        {
            _teamsService.Create(team);

            return(CreatedAtRoute("GetTeam", new { id = team.Id.ToString() }, team));
        }