Ejemplo n.º 1
0
        public IActionResult SaveLangAccToUserId([FromBody] UsersLanguage model)
        {
            try
            {
                //delete record from UserLanguageMapping table
                UserLanguageMapping userLanguage = _context.UserLanguageMapping.Find(model.UserId);
                _context.UserLanguageMapping.Remove(userLanguage);
                _context.SaveChangesAsync();

                //insert all value in UserLanguageMapping
                int count = model.languageId.Count();
                for (int i = 0; i < count; i++)
                {
                    _context.UserLanguageMapping.Add(new UserLanguageMapping
                    {
                        UserId     = model.UserId,
                        LanguageId = model.languageId[i]
                    });
                }
                _context.SaveChangesAsync();
                jsonResponse.IsSuccessful = true;
                jsonResponse.Response     = "Data saved successfully";
                return(Ok(jsonResponse));
            }
            catch (Exception)
            {
                jsonResponse.IsSuccessful = true;
                jsonResponse.Response     = "Exception Occured";
                return(BadRequest(jsonResponse));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Register([FromBody] LoginDetails user)
        {
            try
            {
                _userRepo.Create(user);

                _masterContext.UserInfo.Add(
                    new UserInfo
                {
                    UserId          = user.UserId,
                    Name            = string.Empty,
                    Age             = 0,
                    Gender          = string.Empty,
                    LangId1         = 1,//TODO
                    LangId2         = -1,
                    LangId3         = -1,
                    QualificationId = -1
                });
                await _masterContext.SaveChangesAsync();

                return(Created("", user.UserId));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }