Example #1
0
        public ActionResult CreateNewAccount(UsersPO form)
        {
            ActionResult response;

            //checking modelstate
            if (ModelState.IsValid)
            {
                try
                {
                    //taking user input and mapping it to the database
                    form.RoleID = 3;

                    UsersDO newUser = Mapper.UsersPOtoUsersDO(form);
                    _UsersDAO.CreateNewUserEntry(newUser);
                    //setting response view
                    response = RedirectToAction("Login", "Users");
                }
                //logging errors
                catch (SqlException sqlEx)
                {
                    Logger.SqlErrorLog(sqlEx);
                    response = View("Error");
                }
                catch (Exception ex)
                {
                    Logger.ErrorLog(ex);
                    response = View("Error");
                }
            }
            else
            {
                //returning to form view if model state is invalid
                response = View(form);
            }
            //return view page
            return(response);
        }