Exemplo n.º 1
0
        public ActionResult AddColleague(AdministrationUserModel model)
        {
            bool isUserSaved = false;

            model.LevelsOfAccess = _userService.GetUserLevelsOfAccess();

            // Check is userId is unique
            if (!String.IsNullOrEmpty(model.UserId))
            {
                if (model.UserId.Length < 26)
                {
                    if (_userService.IsUserIdExist(model.UserId))
                    {
                        ModelState.AddModelError("UserId", "That ID already exists. ");
                    }
                }
                else
                {
                    ModelState.AddModelError("UserId", "ID should not be more than 25");
                }
            }

            model.StoreNumber    = _storeService.GetStoreId();
            model.LevelsOfAccess = _userService.GetUserLevelsOfAccess();


            if (ModelState.IsValid)
            {
                //Check date of birth
                bool?  errorVariableIsYear;
                string errorMessage = CAST.Validation.DateOfBirthValidation.Check(model.Year, model.Month, model.Day, out errorVariableIsYear);

                if (!string.IsNullOrEmpty(errorMessage))
                {
                    if (errorVariableIsYear.Value)
                    {
                        ModelState.AddModelError("Year", errorMessage);
                    }
                    else
                    {
                        ModelState.AddModelError("Day", errorMessage);
                    }
                }
                else // Create new user
                {
                    if (_storeService.IsCallCenter())
                    {
                        isUserSaved = _adminService.AddNewContactCenterColleague(model, _userService.GetUserId());
                    }
                    else
                    {
                        isUserSaved = _adminService.AddNewColleague(model, _userService.GetUserId());
                    }
                }
            }
            ViewBag.IsCallCenter   = _storeService.IsCallCenter();
            ViewBag.IsSavedSuccess = isUserSaved;
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AddColleague(AdministrationUserModel model)
        {
            bool isUserSaved = false;

            model.LevelsOfAccess = _userService.GetUserLevelsOfAccess();

            // Check is userId is unique
            if (!String.IsNullOrEmpty(model.UserId))
            {
                if (model.UserId.Length < 26)
                {
                    if (_userService.IsUserIdExist(model.UserId))
                    {
                        ModelState.AddModelError("UserId", "That ID already exists. ");
                    }
                }
                else
                {
                    ModelState.AddModelError("UserId", "ID should not be more than 25");
                }
            }
            model.StoreNumber    = _storeService.GetStoreId();
            model.LevelsOfAccess = _userService.GetUserLevelsOfAccess();

            // Create new user
            if (ModelState.IsValid)
            {
                if (_storeService.IsCallCenter())
                {
                    isUserSaved = _adminService.AddNewContactCenterColleague(model, _userService.GetUserId());
                }
                else
                {
                    isUserSaved = _adminService.AddNewColleague(model, _userService.GetUserId());
                }
            }
            ViewBag.IsCallCenter   = _storeService.IsCallCenter();
            ViewBag.IsSavedSuccess = isUserSaved;
            return(View(model));
        }