public IActionResult UpdateLanguage([FromBody] dynamic requestModel, [FromRoute] string id) { try { var userId = requestModel["UserId"].Value.ToString(); var jsonObject = ((Newtonsoft.Json.Linq.JProperty)((Newtonsoft.Json.Linq.JContainer)requestModel).Last).Value; var entity = JsonParserHelper.ParseToKEntity(jsonObject); var tempCommand = new CreateOrUpdateLanguageEntityRequestModel() { Entity = entity, UserId = userId, LanguageId = id }; var validationResult = requestModel.Validate(); if (validationResult.Any()) { return(BadRequest(validationResult)); } return(Ok(MongoConnector.CreateOrUpdateLanguageEntity(requestModel))); } catch (Exception ex) { return(BadRequest(ex)); } }
public IActionResult CreateLanguage([FromBody] dynamic requestModel) { try { var userId = requestModel["UserId"] != null ? requestModel["UserId"].Value.ToString() : null; if (Request.Headers.ContainsKey("Authorization")) { userId = Request.Headers.ContainsKey("Authorization") ? Request.Headers["Authorization"].ToString() : userId; } var jsonObject = ((Newtonsoft.Json.Linq.JProperty)((Newtonsoft.Json.Linq.JContainer)requestModel).Last).Value; var entity = JsonParserHelper.ParseToKEntity(jsonObject); var tempCommand = new CreateOrUpdateLanguageEntityRequestModel() { UserId = userId, Entity = entity }; var validationResult = requestModel.Validate(); if (validationResult.Any()) { return(BadRequest(validationResult)); } return(Ok(MongoConnector.CreateOrUpdateLanguageEntity(requestModel))); } catch (Exception ex) { return(BadRequest(ex)); } }