Beispiel #1
0
        public ActionResult UserEdit()
        {
            EditUser_BusinessLayer       editUserListBusinessLayer = new EditUser_BusinessLayer();
            EditUser_Model_BusinessLayer editUserData_Model        = editUserListBusinessLayer.editUser_DataGet();

            ViewBag.DisplayAddUser = false;  // Displays Partial View for Edit User functionality
            return(View(editUserData_Model));
        }
Beispiel #2
0
        public ActionResult UpdateUser(string selecteduser_ID)
        {
            User_Model_BusinessLayer selectedUserRetrievedData = new User_Model_BusinessLayer();
            EditUser_BusinessLayer   getSelectedUserData       = new EditUser_BusinessLayer(); // Will hold the personal data of the user to be edited

            List <Junc_Email_Dest_Model_BusinessLayer> selectedUserRetrievedJuncEmailDataList = new List <Junc_Email_Dest_Model_BusinessLayer>();
            EditUser_BusinessLayer getSelectedUserJuncEmailDataList = new EditUser_BusinessLayer();        // Will hold the email data of the user to be edited

            User_Model_BusinessLayer modelWithSelectedUserProfile   = new User_Model_BusinessLayer();
            EditUser_BusinessLayer   getDataForModelWithUserProfile = new EditUser_BusinessLayer();      // Will be the model used to build the Edit User interface

            try
            {
                selectedUserRetrievedData = getSelectedUserData.Get_User_Data_Cursor(selecteduser_ID);                              // Will retrieve the personal data of the user to be edited
                selectedUserRetrievedJuncEmailDataList = getSelectedUserJuncEmailDataList.Get_User_Email_Cursor(selecteduser_ID);   // Will retrieve the email data of the user to be edited

                if (!(selectedUserRetrievedJuncEmailDataList.Count == 0))                                                           //There is email's data in the table
                {
                    var    emailCode_Dictionary = new Dictionary <string, string>();
                    string e_mailCondition      = "N";
                    foreach (Junc_Email_Dest_Model_BusinessLayer emailItem in selectedUserRetrievedJuncEmailDataList)
                    {
                        if (emailItem.P_EMAIL == "Y")
                        {
                            e_mailCondition = "P";
                        }
                        else
                        {
                            e_mailCondition = "N";
                        }

                        emailCode_Dictionary.Add(emailItem.EMAIL_REASON_CODE, e_mailCondition);
                    }

                    ViewData["emailDict"] = emailCode_Dictionary;
                }
                else
                {
                    Session["mssgCont"] = "No email records were found for user ID " + selecteduser_ID.ToString() + ". Information could be deleted or corrupted";

                    return(RedirectToAction("UserEdit"));
                }


                string userSelected_RoleID       = selectedUserRetrievedData.ROLE_ID.ToString();
                string userSelected_ContractorID = selectedUserRetrievedData.CONTRACTOR_ID.ToString();
                modelWithSelectedUserProfile = getDataForModelWithUserProfile.editUserForUpdate_DataGet(userSelected_RoleID, userSelected_ContractorID); // Retrieves user's role and contractor as selected in the corresponding dropdownlist

                modelWithSelectedUserProfile.USER_ID   = selectedUserRetrievedData.USER_ID;                                                              //populates model for rendering user data
                modelWithSelectedUserProfile.LAST_NAME = selectedUserRetrievedData.LAST_NAME;

                return(View(modelWithSelectedUserProfile));
            }
            catch (Exception err)
            {
                string errMssg = "Error reading juncEmail table (using SP: sel_junc_email_dest) at UserMaintenanceController level: " + err.Message;

                //return View("Error",)

                ViewBag.mssgBack_Email = "Error reading data from the database, check connection is up and try again ";

                return(RedirectToAction("UserEdit"));
                // throw;
            }

            //return RedirectToAction("UserEdit");
        }