public ActionResult UpdateData(string txtUSERNAME, string txtFULL_NAME, string txtPASSWORD, string txtGROUPID, string txtAREA, string txtRW_ACCESS, string txtAUTORIZATION, string txtPTT_STATE, string txtHANDOVER, string txtUSER_ROLES, string txtEXC, string txtEMAIL, string txtNO_TEL, string targetGroup)
        {
            bool success = true;


            WebView.WebService._base myWebService;
            myWebService = new WebService._base();
            //string password = Crypto.EncryptStringAES(txtPASSWORD);
            System.Diagnostics.Debug.WriteLine("Not Update!" + txtUSERNAME);
            WebService._base.UserMaintenance newUser = new WebService._base.UserMaintenance();
            System.Diagnostics.Debug.WriteLine("UPDATE!! :" + txtUSERNAME);
            newUser.FULL_NAME = txtFULL_NAME;
            //newUser.PASSWORD = password;
            newUser.PASSWORD     = txtPASSWORD;
            newUser.GROUPID      = txtGROUPID;
            newUser.AREA         = txtAREA;
            newUser.RW_ACCESS    = txtRW_ACCESS;
            newUser.AUTORIZATION = txtAUTORIZATION;
            newUser.PTT_STATE    = txtPTT_STATE;
            newUser.HANDOVER     = txtHANDOVER;
            newUser.USER_ROLES   = txtUSER_ROLES;
            newUser.EXC          = txtEXC;
            newUser.EMAIL        = txtEMAIL;
            newUser.NO_TEL       = txtNO_TEL;

            success = myWebService.UpdateUser(newUser, txtUSERNAME, targetGroup);

            return(Json(new
            {
                Success = success
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            bool   success = true;
            string oldPass = "";
            string crrUsr  = "";

            WebView.WebService._base myWebService;
            myWebService = new WebService._base();
            using (Entities ctxData = new Entities())
            {
                var query = (from p in ctxData.WV_USER
                             where p.USERNAME == User.Identity.Name
                             select new { p.PASSWORD, p.USERNAME }).Single();

                oldPass = query.PASSWORD;
                crrUsr  = query.USERNAME;
            }
            // encrypt the password
            string oldpassword = Crypto.EncryptStringAES(model.OldPassword);
            string password    = Crypto.EncryptStringAES(model.NewPassword);

            System.Diagnostics.Debug.WriteLine(password);
            if (oldPass == model.OldPassword)
            {
                WebService._base.UserMaintenance newUser = new WebService._base.UserMaintenance();
                newUser.PASSWORD = model.NewPassword;
                success          = myWebService.UpdateUserPass(newUser, crrUsr);
                if (success == true)
                {
                    return(RedirectToAction("ChangePasswordSuccess"));
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }
            else
            {
                ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public ActionResult ChangePass(string UserName, string Old_Pass, string New_Pass)
        {
            bool success = true;

            // System.Diagnostics.Debug.WriteLine("UPDATE!! :" + UserName + "Old Pass: "******"new Pass : "******"P :" + success);
            return(Json(new
            {
                Success = success
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Register(RegisterModel model)
        {
            bool success = true;

            WebView.WebService._base myWebService;
            myWebService = new WebService._base();

            bool selected = false;

            WebService._base.UserMaintenance newUserMaintenance = new WebService._base.UserMaintenance();
            // encrypt the password
            //string password = Crypto.EncryptStringAES(model.PASSWORD);

            newUserMaintenance.USERNAME  = model.USERNAME.ToUpper();
            newUserMaintenance.FULL_NAME = model.FULL_NAME;
            newUserMaintenance.PASSWORD  = model.PASSWORD;
            //newUserMaintenance.PASSWORD = password;
            newUserMaintenance.GROUPID      = model.GROUPID;
            newUserMaintenance.AREA         = model.AREA;
            newUserMaintenance.RW_ACCESS    = model.RW_ACCESS;
            newUserMaintenance.AUTORIZATION = model.AUTORIZATION;
            newUserMaintenance.NETWORK      = model.NETWORK;
            newUserMaintenance.PTT_STATE    = model.PTT_STATE;
            newUserMaintenance.HANDOVER     = model.HANDOVER;
            newUserMaintenance.USER_ROLES   = model.USER_ROLES;
            newUserMaintenance.EXC          = model.EXC;
            newUserMaintenance.EMAIL        = model.Email;
            newUserMaintenance.NO_TEL       = model.NO_TEL;
            newUserMaintenance.REGION       = model.REGIONID;
            newUserMaintenance.NATIONS      = model.NATION;


            System.Diagnostics.Debug.WriteLine("ID 1: " + model.NATION);
            System.Diagnostics.Debug.WriteLine("ID 2: " + model.REGIONID);
            success = myWebService.AddUser(newUserMaintenance);
            System.Diagnostics.Debug.WriteLine(success);
            selected = true;

            // If we got this far, something failed, redisplay form
            List <SelectListItem> list = new List <SelectListItem>();

            using (Entities ctxData = new Entities())
            {
                var query = from p in ctxData.WV_GROUP
                            orderby p.FULL_NAME
                            select new { Text = p.FULL_NAME, Value = p.GRP_ID };

                foreach (var a in query)
                {
                    list.Add(new SelectListItem()
                    {
                        Text = a.Text, Value = a.Value.ToString()
                    });
                }

                ViewBag.groupID = list;
            }
            List <SelectListItem> list2 = new List <SelectListItem>();

            using (Entities ctxData = new Entities())
            {
                var query1 = from p in ctxData.WV_ROLE
                             orderby p.ROLENAME
                             select new { Text = p.ROLENAME, Value = p.ROLENAME };

                foreach (var a in query1)
                {
                    list2.Add(new SelectListItem()
                    {
                        Text = a.Text, Value = a.Value
                    });
                }

                ViewBag.roleID = list2;
            }
            List <SelectListItem> list3 = new List <SelectListItem>();

            list3.Add(new SelectListItem()
            {
                Text = "AUTO", Value = "AUTO"
            });
            list3.Add(new SelectListItem()
            {
                Text = "MANUAL", Value = "MANUAL"
            });
            list3.Add(new SelectListItem()
            {
                Text = "N/A", Value = "N/A"
            });

            ViewBag.handoverState = list3;
            List <SelectListItem> list4 = new List <SelectListItem>();

            list4.Add(new SelectListItem()
            {
                Text = "ALL", Value = "ALL"
            });
            using (Entities ctxData = new Entities())
            {
                var query3 = from p in ctxData.WV_PTT_EXC_MAST
                             orderby p.PTT_ID ascending
                             select new { Text = p.PTT_ID, Value = p.PTT_ID };

                foreach (var a in query3.Distinct())
                {
                    list4.Add(new SelectListItem()
                    {
                        Text = a.Text, Value = a.Value
                    });
                }

                ViewBag.pttID = list4;
            }
            //if (ModelState.IsValid)
            //{
            // Attempt to register the user
            if (success == true)
            {
                //return RedirectToAction("NewSave?res=" + result);
                return(RedirectToAction("NewSave"));
            }
            else
            {
                return(RedirectToAction("NewSaveFail")); // store to db failed.
            }
            //}
            //return View(model);
        }