コード例 #1
0
        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" });
            //}
        }
コード例 #2
0
 public ActionResult AddLanguage([FromBody] AddLanguageViewModel language)
 {
     //Your code here;
     // TODO: Add language
     _profileService.AddNewLanguage(language);
     return(Json(new { Success = true }));
 }
コード例 #3
0
 public ActionResult AddLanguage([FromBody] AddLanguageViewModel language)
 {
     {
         if (ModelState.IsValid)
         {
             if (_profileService.AddNewLanguage(language))
             {
                 return(Json(new { Success = true }));
             }
         }
         return(Json(new { Success = false }));
     }
 }
コード例 #4
0
        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 }));
        }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: ProfileController.cs プロジェクト: stimulate/Talent
        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 }));
        }
コード例 #7
0
        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" }));
            }
        }
コード例 #8
0
        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" }));
            }
        }