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")); }
public ActionResult <Team> Create([FromBody] Team newTeam) { try { return(Ok(_ts.Create(newTeam))); } catch (Exception e) { return(BadRequest(e.Message)); } }
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)); } }
public ActionResult <TeamsDocument> CreateTeam(TeamsDocument team) { _teamsService.Create(team); return(CreatedAtRoute("GetTeam", new { id = team.Id.ToString() }, team)); }
public ActionResult <Team> Create([FromBody] Team team) { _teamsService.Create(team); return(CreatedAtRoute("GetTeam", new { id = team.Id.ToString() }, team)); }