// GET: RpasUser/Edit/5 public ActionResult Edit(int?id) { if (!exLogic.User.hasAccess("RPASUSER.EDIT")) { return(RedirectToAction("NoAccess", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MSTR_User mSTR_User = db.MSTR_User.Find(id); MSTR_User_Pilot mSTR_User_Pilot = db.MSTR_User_Pilot.Find(id); if (mSTR_User == null) { return(HttpNotFound()); } var viewModel = new ViewModel.UserViewModel { User = mSTR_User, Pilot = mSTR_User_Pilot, ProfileList = Util.GetProfileList(), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), AccountList = Util.GetAccountList(), DashboardList = Util.GetDashboardLists(), PermitCategoryList = Util.GetLists("RPASCategory") }; return(View(viewModel)); //return View(mSTR_User); }
public IActionResult Post([FromBody] ViewModel.UserViewModel userViewModel) { /*判断是否合法*/ if (ModelState.IsValid) { try { if (!HelpCenter.BLL.Usr.CheckAccount(userViewModel.UsrAccount)) { return(Ok(new { result = false, tips = ResponseMessageTips.MSG_USR_IS_EXIST })); } string strUsrInfo = string.Empty; bool isUsrAdd = HelpCenter.BLL.Usr.Add(userViewModel.UsrPhoneNum, userViewModel.UsrAccount, userViewModel.UsrPsw, userViewModel.UsrName, userViewModel.UsrDeptId, userViewModel.UsrState, User.Identity.IsAuthenticated? User.Identities.First(u => u.IsAuthenticated).FindFirst("UsrId").Value:string.Empty, userViewModel.UsrType, userViewModel.UsrVerifyState, userViewModel.RoleIdList); return(!isUsrAdd ? Ok(new { result = false, tips = ResponseMessageTips.MSG_USR_ADD_FAIL }) : Ok(new { result = true, tips = ResponseMessageTips.MSG_USR_ADD_SUCCESS })); } catch (Exception e) { return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_EXCEPTION + e.Message.ToString() })); } } return(Ok(new { result = false, tips = ResponseMessageTips.MSG_PROCESS_DATA_FORMAT_ERROR })); }
public ActionResult ListUser() { var model = new ViewModel.UserViewModel(); model.ListOfUser = _userRepository.GetAllUser(); return(View(model)); }
// GET: RpasUser/Create public ActionResult Create([Bind(Prefix = "ID")] int RPASID = 0) { if (!exLogic.User.hasAccess("RPASUSER.CREATE")) { return(RedirectToAction("NoAccess", "Home")); } MSTR_User EPASValues = new MSTR_User(); if (RPASID != 0) { ViewBag.RPASid = RPASID; //ViewBag.IsPassowrdRequired = false; var RPASoList = (from p in db.MSTR_RPAS_User where p.RpasId == RPASID select p).ToList(); EPASValues.FirstName = RPASoList[0].Name; EPASValues.CountryId = Convert.ToInt16(RPASoList[0].NationalityId); EPASValues.EmiratesID = RPASoList[0].EmiratesId; EPASValues.EmailId = RPASoList[0].EmailId; EPASValues.MobileNo = RPASoList[0].MobileNo; //EPASValues.UserProfileId = Convert.ToInt16(7); //EPASValues.Dashboard = "RPAS"; //EPASValues.IsActive = false; //EPASValues.IsPilot = false; } var viewModel = new ViewModel.UserViewModel { User = EPASValues, Pilot = new MSTR_User_Pilot(), ProfileList = Util.GetProfileList(), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), AccountList = Util.GetAccountList(), DashboardList = Util.GetDashboardLists(), PermitCategoryList = Util.GetLists("RPASCategory") }; return(View(viewModel)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserViewControl_Loaded(object sender, RoutedEventArgs e) { ViewModel.UserViewModel UserViewModelObject = new ViewModel.UserViewModel(); }
public Profil() { this.InitializeComponent(); DataContext = new ViewModel.UserViewModel(); }
public ActionResult Edit(ViewModel.UserViewModel UserModel, int ID = 0) { if (!exLogic.User.hasAccess("RPASUSER.EDIT")) { return(RedirectToAction("NoAccess", "Home")); } string hdnRPASid = Request["hdnRPASid"]; ModelState.Remove("User.AccountId"); ModelState.Remove("User.UserProfileId"); ModelState.Remove("User.IsActive"); ModelState.Remove("User.IsPilot"); if (String.IsNullOrEmpty(UserModel.User.RPASPermitNo)) { ModelState.AddModelError("User.RPASPermitNo", "Please enter the RPAS Permit Number"); } if (String.IsNullOrEmpty(UserModel.User.PermitCategory)) { ModelState.AddModelError("User.PermitCategory", "Please select the RPAS Permit Category"); } if (String.IsNullOrEmpty(UserModel.User.ContactAddress)) { ModelState.AddModelError("User.ContactAddress", "Please enter Contact Address"); } if (String.IsNullOrEmpty(UserModel.User.RegRPASSerialNo)) { ModelState.AddModelError("User.RegRPASSerialNo", "Please enter RPAS Serial Number"); } if (String.IsNullOrEmpty(UserModel.User.CompanyAddress)) { ModelState.AddModelError("User.CompanyAddress", "Please enter Company Address"); } if (String.IsNullOrEmpty(UserModel.User.CompanyTelephone)) { ModelState.AddModelError("User.CompanyTelephone", "Please enter Company Telephone Number."); } if (String.IsNullOrEmpty(UserModel.User.CompanyEmail)) { ModelState.AddModelError("User.CompanyEmail", "Please enter Company Email"); } if (String.IsNullOrEmpty(UserModel.User.RPASPermitNo)) { ModelState.AddModelError("User.RPASPermitNo", "Please enter the RPAS Permit Number"); } if (String.IsNullOrEmpty(UserModel.Pilot.EmiratesId)) { ModelState.AddModelError("Pilot.EmiratesId", "Emirates ID is required."); } if (String.IsNullOrEmpty(UserModel.Pilot.PassportNo)) { ModelState.AddModelError("Pilot.PassportNo", "Passport Number is required."); } int RPASID = ID; if (ModelState.IsValid) { string SQL = "update MSTR_User set \n" + "UserName = '******', \n" + "FirstName = '" + UserModel.User.FirstName + "', \n" + "MiddleName = '" + UserModel.User.MiddleName + "', \n" + "LastName = '" + UserModel.User.LastName + "', \n" + "MobileNo = '" + UserModel.User.MobileNo + "', \n" + "OfficeNo = '" + UserModel.User.OfficeNo + "', \n" + "HomeNo = '" + UserModel.User.HomeNo + "', \n" + "EmailId = '" + UserModel.User.EmailId + "', \n" + "CountryId = " + Util.toInt(UserModel.User.CountryId) + ", \n" + "PhotoUrl = '" + UserModel.User.PhotoUrl + "', \n" + "RPASPermitNo = '" + UserModel.User.RPASPermitNo + "', \n" + "PermitCategory = '" + UserModel.User.PermitCategory + "', \n" + "ContactAddress = '" + UserModel.User.ContactAddress + "', \n" + "RegRPASSerialNo = '" + UserModel.User.RegRPASSerialNo + "', \n" + "CompanyAddress = '" + UserModel.User.CompanyAddress + "', \n" + "CompanyTelephone = '" + UserModel.User.CompanyTelephone + "', \n" + "CompanyEmail = '" + UserModel.User.CompanyEmail + "', \n" + "EmiratesID = '" + UserModel.Pilot.EmiratesId + "' \n" + "where UserId =" + ID; int id = Util.doSQL(SQL); string SQL1 = "update MSTR_User_Pilot set \n" + "PassportNo = '" + UserModel.Pilot.PassportNo + "',\n" + "DateOfExpiry = '" + UserModel.Pilot.DateOfExpiry + "',\n" + "EmiratesId = '" + UserModel.Pilot.EmiratesId + "'\n " + "where UserId = " + ID; int Pid = Util.doSQL(SQL1); //move the image to correct path String UploadPath = Server.MapPath(Url.Content(RootUploadDir)); String newPath = UploadPath + id + "/"; String PhotoURL = UploadPath + "0/" + UserModel.User.PhotoUrl; if (!System.IO.Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); } if (!String.IsNullOrEmpty(UserModel.User.PhotoUrl) && System.IO.File.Exists(PhotoURL)) { System.IO.File.Move(PhotoURL, newPath + UserModel.User.PhotoUrl); } //to sent mail to the user created //if (id != 0) //{ // var mailurl = "/Email/RPASUserCreated/" + id; // var mailsubject = "User has been created"; // Util.EmailQue(Convert.ToInt32(Session["UserId"].ToString()), "*****@*****.**", mailsubject, "~" + mailurl); // //need to update the RPAS Status after sending mail // SQL = "update mstr_rpas_user set [Status] = 'User Created' where rpasID = " + RPASID; // Util.doSQL(SQL); //} return(RedirectToAction("Index")); } var viewModel = new ViewModel.UserViewModel { User = UserModel.User, Pilot = UserModel.Pilot, ProfileList = Util.GetProfileList(), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), AccountList = Util.GetAccountList(), DashboardList = Util.GetDashboardLists(), PermitCategoryList = Util.GetLists("RPASCategory") }; return(View(viewModel)); }
public ActionResult Create(ViewModel.UserViewModel UserModel, int ID = 0) { if (!exLogic.User.hasAccess("RPASUSER.CREATE")) { return(RedirectToAction("NoAccess", "Home")); } string hdnRPASid = Request["hdnRPASid"]; ModelState.Remove("User.AccountId"); ModelState.Remove("User.UserProfileId"); ModelState.Remove("User.IsActive"); ModelState.Remove("User.IsPilot"); if (String.IsNullOrEmpty(UserModel.User.RPASPermitNo)) { ModelState.AddModelError("User.RPASPermitNo", "Please enter the RPAS Permit Number"); } if (String.IsNullOrEmpty(UserModel.User.PermitCategory)) { ModelState.AddModelError("User.PermitCategory", "Please select the RPAS Permit Category"); } if (String.IsNullOrEmpty(UserModel.User.ContactAddress)) { ModelState.AddModelError("User.ContactAddress", "Please enter Contact Address"); } if (String.IsNullOrEmpty(UserModel.User.RegRPASSerialNo)) { ModelState.AddModelError("User.RegRPASSerialNo", "Please enter RPAS Serial Number"); } if (String.IsNullOrEmpty(UserModel.User.CompanyAddress)) { ModelState.AddModelError("User.CompanyAddress", "Please enter Company Address"); } if (String.IsNullOrEmpty(UserModel.User.CompanyTelephone)) { ModelState.AddModelError("User.CompanyTelephone", "Please enter Company Telephone Number."); } if (String.IsNullOrEmpty(UserModel.User.CompanyEmail)) { ModelState.AddModelError("User.CompanyEmail", "Please enter Company Email"); } if (String.IsNullOrEmpty(UserModel.User.RPASPermitNo)) { ModelState.AddModelError("User.RPASPermitNo", "Please enter the RPAS Permit Number"); } if (String.IsNullOrEmpty(UserModel.Pilot.EmiratesId)) { ModelState.AddModelError("Pilot.EmiratesId", "Emirates ID is required."); } if (String.IsNullOrEmpty(UserModel.Pilot.PassportNo)) { ModelState.AddModelError("Pilot.PassportNo", "Passport Number is required."); } int RPASID = ID; //checking if username or mail already exist if (exLogic.User.UserExist(UserModel.User.UserName) > 0) { ModelState.AddModelError("User.UserName", "This Username already exists."); } if (exLogic.User.EmailExist(UserModel.User.EmailId) > 0) { ModelState.AddModelError("User.EmailId", "Email already exists."); } //if (RPASID == 0) //{ // if (String.IsNullOrEmpty(UserModel.User.Password)) // { // ModelState.AddModelError("User.Password", "Invalid Password.Please enter again."); // } //} if (ModelState.IsValid) { string Password = ""; //if (RPASID == 0) // Password = Util.GetEncryptedPassword(UserModel.User.Password).ToString(); //else // Password = ""; String SQL = "insert into MSTR_User(\n" + " UserName,\n" + " Password,\n" + " FirstName,\n" + " MiddleName,\n" + " LastName,\n" + " CreatedBy,\n" + " UserProfileId,\n" + //" Remarks,\n" + " MobileNo,\n" + " OfficeNo,\n" + " HomeNo,\n" + " EmailId,\n" + " CountryId,\n" + " IsActive,\n" + " CreatedOn,\n" + " AccountId,\n" + " IsPilot, \n" + " PhotoUrl,\n" + " Dashboard,\n" + " RPASPermitNo,\n" + " PermitCategory,\n" + " ContactAddress,\n" + " RegRPASSerialNo,\n" + " CompanyAddress,\n" + " CompanyTelephone,\n" + " CompanyEmail,\n" + " EmiratesID\n" + ") values(\n" + " '" + UserModel.User.UserName + "',\n" + " '" + Password + "',\n" + " '" + UserModel.User.FirstName + "',\n" + " '" + UserModel.User.MiddleName + "',\n" + " '" + UserModel.User.LastName + "',\n" + " " + Util.getLoginUserID() + ",\n" + " 7,\n" + //" '" + UserModel.User.Remarks + "',\n" + " '" + UserModel.User.MobileNo + "',\n" + " '" + UserModel.User.OfficeNo + "',\n" + " '" + UserModel.User.HomeNo + "',\n" + " '" + UserModel.User.EmailId + "',\n" + " " + Util.toInt(UserModel.User.CountryId) + ",\n" + " 'true',\n" + " GETDATE(),\n" + " 23,\n" + " 'true',\n" + " '" + UserModel.User.PhotoUrl + "',\n" + " 'RPAS',\n" + " '" + (UserModel.User.RPASPermitNo) + "',\n" + " '" + (UserModel.User.PermitCategory) + "',\n" + " '" + (UserModel.User.ContactAddress) + "',\n" + " '" + (UserModel.User.RegRPASSerialNo) + "',\n" + " '" + (UserModel.User.CompanyAddress) + "',\n" + " '" + (UserModel.User.CompanyTelephone) + "',\n" + " '" + (UserModel.User.CompanyEmail) + "',\n" + " '" + (UserModel.Pilot.EmiratesId) + "'\n" + ")"; //inserting pilot information to the pilot table int id = Util.InsertSQL(SQL); SQL = "insert into MSTR_User_Pilot(\n" + " UserId,\n" + " PassportNo,\n" + " DateOfExpiry,\n" + //" Department,\n" + " EmiratesId\n" + //" Title\n" + ") values(\n" + " '" + id + "',\n" + " '" + UserModel.Pilot.PassportNo + "',\n" + " '" + UserModel.Pilot.DateOfExpiry + "',\n" + " '" + UserModel.Pilot.EmiratesId + "'\n)"; int Pid = Util.InsertSQL(SQL); //move the image to correct path String UploadPath = Server.MapPath(Url.Content(RootUploadDir)); String newPath = UploadPath + id + "/"; String PhotoURL = UploadPath + "0/" + UserModel.User.PhotoUrl; if (!System.IO.Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); } if (!String.IsNullOrEmpty(UserModel.User.PhotoUrl) && System.IO.File.Exists(PhotoURL)) { System.IO.File.Move(PhotoURL, newPath + UserModel.User.PhotoUrl); } //to sent mail to the user created if (id != 0) { var mailurl = "/Email/RPASUserCreated/" + id; var mailsubject = "User has been created"; Util.EmailQue(Convert.ToInt32(Session["UserId"].ToString()), "*****@*****.**", mailsubject, "~" + mailurl); //need to update the RPAS Status after sending mail SQL = "update mstr_rpas_user set [Status] = 'User Created' where rpasID = " + RPASID; Util.doSQL(SQL); } return(RedirectToAction("UASRegister", "RPAS")); } var viewModel = new ViewModel.UserViewModel { User = UserModel.User, Pilot = UserModel.Pilot, ProfileList = Util.GetProfileList(), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), AccountList = Util.GetAccountList(), DashboardList = Util.GetDashboardLists(), PermitCategoryList = Util.GetLists("RPASCategory") }; return(View(viewModel)); }
public ActionResult Edit(int id, ViewModel.PilotEditModel UserModel) { //String Pass_SQL = "\n"; if (!exLogic.User.hasAccess("PILOTS.EDIT")) { id = Util.getLoginUserID(); } if (!exLogic.User.hasAccess("ORGANIZATION.ADMIN")) { id = Util.getLoginUserID(); } if (ModelState.IsValid) { int AccountID = Util.getAccountID(); UserModel.UserId = id; string SQL = "UPDATE MSTR_USER SET\n" + " FirstName='" + Util.FirstLetterToUpper(UserModel.FirstName) + "',\n" + " MiddleName='" + Util.FirstLetterToUpper(UserModel.MiddleName) + "',\n" + " LastName='" + Util.FirstLetterToUpper(UserModel.LastName) + "',\n" + " Remarks='" + UserModel.Remarks + "',\n" + " MobileNo='" + UserModel.MobileNo + "',\n" + " EmailId='" + UserModel.EmailId + "',\n" + " CountryId=" + Util.toInt(UserModel.CountryId.ToString()) + ",\n" + " OfficeNo='" + UserModel.OfficeNo + "',\n" + " HomeNo='" + UserModel.HomeNo + "',\n" + " PhotoUrl='" + UserModel.PhotoUrl + "',\n" + " RPASPermitNo='" + UserModel.RPASPermitNo + "',\n" + " PermitCategory='" + UserModel.PermitCategory + "',\n" + " DOE_RPASPermit='" + UserModel.DOE_RPASPermit + "',\n" + " DOI_RPASPermit='" + UserModel.DOI_RPASPermit + "',\n" + " EmiratesId='" + UserModel.EmiratesID + "',\n" + " Nationality='" + UserModel.Nationality + "'\n"; if (!String.IsNullOrWhiteSpace(UserModel.ConfirmPassword)) { SQL += "," + " [Password]='" + Util.MD5(UserModel.ConfirmPassword.ToLower()) + "'\n"; } SQL += " where\n" + " UserId=" + id; Util.doSQL(SQL); //updating pilot information to pilot table SQL = "UPDATE MSTR_USER_PILOT SET\n" + " DateOfExpiry='" + UserModel.DateOfExpiry + "',\n" + " PassportNo= '" + UserModel.PassportNo + "',\n" + " Department='" + UserModel.Department + "',\n" + " EmiratesId='" + UserModel.EmiratesID + "',\n" + " Title='" + UserModel.Department + "'\n" + "where\n" + " UserId=" + id; ; int idPilot = Util.doSQL(SQL); MovePhto(UserModel.PhotoUrl, id); if (exLogic.User.hasAccess("ORGANIZATION.ADMIN")) { UpdateLinkedDrone(UserModel.LinkedDroneID, id); } return(RedirectToAction("Index", "Home")); } var viewModel = new ViewModel.UserViewModel { // ProfileList = Util.GetProfileList(), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), // AccountList = Util.GetAccountList(), // DashboardList = Util.GetDashboardLists(), PermitCategoryList = Util.GetLists("RPASCategory") }; return(View(viewModel)); }//ActionEdit()