public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { TResponse objTResponse = new UserProfileBusiness().UserProfileLogin(model); if (objTResponse.ResponsePacket != null) { UserProfileModel objUserProfileModel = objTResponse.ResponsePacket as UserProfileModel; if (objUserProfileModel != null && objUserProfileModel.Type == "Admin") { UserSession.UserId = objUserProfileModel.UserId; UserSession.UserType = objUserProfileModel.Type; return(RedirectToAction("Index", "AdminUser")); } else if (objUserProfileModel != null && objUserProfileModel.Type == "User") { UserSession.UserId = objUserProfileModel.UserId; UserSession.UserType = objUserProfileModel.Type; return(RedirectToAction("Index", "PilotUser")); } } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View(model)); }
private void FillCustomers() { TResponse objTResponse = new UserProfileBusiness().GetAllUserByType("Customer"); if (objTResponse.ResponsePacket != null) { List <UserProfileModel> lstUserProfileModel = objTResponse.ResponsePacket as List <UserProfileModel>; cmbCustomers.DisplayMemberPath = "FName"; cmbCustomers.SelectedValuePath = "UserId"; cmbCustomers.ItemsSource = lstUserProfileModel; cmbCustomers.SelectedIndex = -1; } }
public ActionResult Add(int id = 0) { objTResponse = new CustomerLocationBusiness().GetByID(id); TResponse objTResponse_ = new UserProfileBusiness().GetAllUserByType("Customer"); ViewBag.CustomerList = (objTResponse_.ResponsePacket as List <UserProfileModel>).Select(c => new SelectListItem { Text = c.FName + " " + c.LName, Value = c.UserId.ToString(), Selected = (c.UserId == (id == 0?0:(objTResponse.ResponsePacket as CustomerLocationModel).CustomerID)) }).ToList(); return(View(objTResponse.ResponsePacket)); }
public ActionResult Profile(string key, int?page) { try { ViewData["key"] = key; int currentPageIndex = page.HasValue ? page.Value : 1; IList <UserProfile> list = new UserProfileBusiness().GetByKey(key).ToPagedList(currentPageIndex, 20); return(View((IPagedList <UserProfile>)list)); } catch (FaultException ex) { var exep = Function.GetExeption(ex); var codeExp = exep[1]; string url = "Error/ErrorFunction/" + codeExp; return(RedirectToActionPermanent(url)); } }
public JsonResult UpdateUserProfile(Common.UserProfile obj) { try { UserProfileBusiness _userProfileBusiness = new UserProfileBusiness(); var entity = _userProfileBusiness.GetById(obj.Id); entity.Code = obj.Code; entity.Address = obj.Address; entity.Dob = obj.Dob; entity.Email = obj.Email; entity.Name = obj.Name; entity.Phone = obj.Phone; entity.Id = obj.Id; entity.Dob = obj.Dob; entity.DepartmentId = obj.DepartmentId; entity.Description = obj.Description; _userProfileBusiness.Edit(entity); return(Json(1));//Cập nhật thành công } catch (Exception) { throw; } }
private void btnSubmitLogin_Click(object sender, RoutedEventArgs e) { try { if (txtEmail.Text.Trim().Length == 0) { lblMsg.Content = "Enter an email."; txtEmail.Focus(); return; } else if (!Regex.IsMatch(txtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { lblMsg.Content = "Enter a valid email."; txtEmail.Select(0, txtEmail.Text.Length); txtEmail.Focus(); return; } else if (txtPin.Password.Trim().Length == 0) { lblMsg.Content = "Enter password."; txtPin.Focus(); //return; } else { TResponse objTResponse = new UserProfileBusiness().UserProfileLogin(new LoginModel { Email = txtEmail.Text.Trim(), Password = txtPin.Password.Trim(), RememberMe = false, Type = "Pilot" }); if (objTResponse.ResponsePacket != null) { UserProfileModel objPilotModel = objTResponse.ResponsePacket as UserProfileModel; if (objPilotModel != null) { PilotSession.UserName = objPilotModel.FName + " " + objPilotModel.LName; PilotSession.UserId = objPilotModel.UserId; PilotSession.UserEmail = objPilotModel.Email; txtEmail.Text = string.Empty; txtPin.Password = string.Empty; MDIWindow md = new MDIWindow(); this.Close(); md.Show(); } else { lblMsg.Content = "Sorry! Please enter existing emailid/password."; reset(); } } else { lblMsg.Content = "Sorry! Please enter existing emailid/password."; reset(); } } } catch (Exception ex) { //PopupBox frmPopup = new PopupBox("Error", ex.Message, MessageBoxImage.Error); //frmPopup.ShowDialog(); } }