public ActionResult AddLanguage([FromBody] AddLanguageViewModel language) { //Your code here; if (ModelState.IsValid) { if (_profileService.AddNewLanguage(language)) { return(Json(new { Success = true })); } } return(Json(new { Success = false })); //try //{ // var languageResult = await _profileService.AddNewLanguage(language); // //var languageResult = await _profileService.AddNewLanguage(language); // if (languageResult == false) // { // return Json(new { success = false, data = "can not add the language." }); // } // return Json(new { Success = true, data = "add successful" }); //} //catch (Exception e) //{ // return Json(new { success = false, data = "error" }); //} }
public ActionResult AddLanguage([FromBody] AddLanguageViewModel language) { //Your code here; // TODO: Add language _profileService.AddNewLanguage(language); return(Json(new { Success = true })); }
public ActionResult AddLanguage([FromBody] AddLanguageViewModel language) { { if (ModelState.IsValid) { if (_profileService.AddNewLanguage(language)) { return(Json(new { Success = true })); } } return(Json(new { Success = false })); } }
public async Task <ActionResult> AddLanguage([FromBody] AddLanguageViewModel language) { //Your code here; // throw new NotImplementedException(); if (ModelState.IsValid) { if (await _profileService.AddNewLanguage(language, _userAppContext.CurrentUserId)) { return(Json(new { Success = true })); } } return(Json(new { Success = false })); }
public async Task <IActionResult> AddLanguage([FromBody] AddLanguageViewModel language) { language.CurrentUserId = _userAppContext.CurrentUserId; var isLanguageAdded = _profileService.AddNewLanguage(language); if (ModelState.IsValid) { if (isLanguageAdded) { return(Json(new { Success = true })); } } return(Json(new { Success = false })); //throw new NotImplementedException(); }
public async Task <IActionResult> AddLanguage([FromBody] AddLanguageViewModel language) { //if (ModelState.IsValid) //{ var user = (await _userRepository.GetByIdAsync(_userAppContext.CurrentUserId)); if (user.Id == language.CurrentUserId) { var x = await _profileService.AddNewLanguage(language); return(Json(new { success = x })); } // } return(Json(new { Success = false })); }
public async Task <ActionResult> AddLanguage([FromBody] AddLanguageViewModel language) { try { var result = await _profileService.AddNewLanguage(language); if (result == false) { return(Json(new { Success = false, data = "can not add the language." })); } return(Json(new { Success = true, data = "add successful" })); } catch (Exception e) { return(Json(new { Success = false, data = "error" })); } }
public ActionResult AddLanguage([FromBody] AddLanguageViewModel language) { //Your code here; //throw new NotImplementedException(); try { string message = ""; if (language.Id == "") { language.Id = ObjectId.GenerateNewId().ToString(); _profileService.AddNewLanguage(language); message = "Language added successfully"; } return(Json(new { Success = true, Message = message })); } catch { return(Json(new { Success = false, Message = "Error while adding language" })); } }