public ApiResponseViewModel Create(UserAccount obj)
 {
     if (HttpContext.Current.Session["UserLogged"] == null)
     {
         return(CommonConstants.accessDenied);
     }
     return(_userAccountService.Add(obj));
 }
Exemple #2
0
 public IActionResult Add(UserLoginDto userLoginDto)
 {
     if (ModelState.IsValid)
     {
         _userAccountService.Add(userLoginDto);
         return(Ok("Ekleme işlemi başarılı"));
     }
     return(BadRequest("Ekleme işlemi başarısız"));
 }
Exemple #3
0
        public ActionResult New(UserProfile userInfo)
        {
            if (!ModelState.IsValid)
            {
                init();
                return(View());
            }

            if (userInfo.Password != userInfo.PasswordConfirm)
            {
                ViewBag.passworDoNotMatch = "Password must match!";
                init();
                return(View());
            }

            var user_ = _userService.FindBy(u => u.UserName == userInfo.UserName).FirstOrDefault();


            var user = new UserProfile();

            user.UserName  = userInfo.UserName;
            user.Password  = _userService.HashPassword(userInfo.Password);
            user.ProgramId = userInfo.ProgramId;
            // Set default values for required fields
            user.Disabled       = false;
            user.LockedInInd    = false;
            user.ActiveInd      = true;
            user.NumberOfLogins = 0;


            Dictionary <string, List <string> > roles = new Dictionary <string, List <string> >();

            user.FirstName    = userInfo.FirstName;
            user.LastName     = userInfo.LastName;
            user.RegionalUser = userInfo.RegionalUser;
            user.RegionID     = userInfo.RegionID;
            user.CaseTeam     = userInfo.CaseTeam;
            user.IsAdmin      = userInfo.IsAdmin;

            user.LanguageCode             = "EN";
            user.Keyboard                 = "AM";
            user.PreferedWeightMeasurment = "MT";
            user.DatePreference           = "GC";
            user.DefaultTheme             = "Default";
            user.FailedAttempts           = 0;
            user.LoggedInInd              = false;
            user.Email = userInfo.Email;

            user.DefaultHub = userInfo.DefaultHub ?? userInfo.DefaultHub;


            if (user_ != null)
            {
                ViewBag.Error = "User Name exits!.Please choose a different User Name!";
                init();
                return(View());
            }

            if (_userService.Add(user, roles))
            {
                if (user.DefaultHub.HasValue)
                {
                    var _savedUser = _userService.FindBy(u => u.UserName == userInfo.UserName).FirstOrDefault();
                    _userHubServcie.AddUserHub(user.DefaultHub.Value, _savedUser.UserProfileID);
                }
                return(View("Index"));
            }
            return(View());
        }