/// <summary> /// Update Team by Id. /// </summary> /// <param name="id"></param> /// <param name="team"></param> /// <returns></returns> /// <response code="200">Returns the newly-created item</response> /// <response code="400">If the item is null</response> public IHttpActionResult Put([FromBody] Team team, string id) { List <string> errors = ValidateExtensions.ValidateTeam(team); if (errors.Count > 0) { return(Content(HttpStatusCode.BadRequest, errors)); } try { if (TimeUnit.Teams.Get(id) == null) { return(NotFound()); } TimeUnit.Teams.Update(team, id); TimeUnit.Save(); Utility.Log($"ROLE CONTROLLER: Put Called on Role, Successfully updated id: {id}.", "INFO"); return(Ok(TimeFactory.Create(team))); } catch (Exception ex) { Utility.Log($"ROLE CONTROLLER: Put Cannot be called on Role.", "ERROR", ex); return(BadRequest(ex.Message)); } }
/// <summary> /// Insert Team. /// </summary> /// <param name="team"></param> /// <returns></returns> /// <response code="200">Returns the newly-created item</response> /// <response code="400">If the item is null</response> public IHttpActionResult Post([FromBody] Team team) { try { List <string> errors = ValidateExtensions.ValidateTeam(team); if (errors.Count > 0) { return(Content(HttpStatusCode.BadRequest, errors)); } TimeUnit.Teams.Insert(team); TimeUnit.Save(); Utility.Log($"TEAM CONTROLLER: Post Called on Team, Successfully added: {team.Name}.", "INFO"); return(Ok(TimeFactory.Create(team))); } catch (Exception ex) { Utility.Log($"TEAM CONTROLLER: Post Cannot be called on Team.", "ERROR", ex); return(BadRequest(ex.Message)); } }