public FundRequestProcessingController() { clientBusinessLogic = new ClientBusinessLogic(); userBusinessLogic = new UserBusinessLogic(); referenceBusinessLogic = new ReferenceBusinessLogic(); fundRequestBusinessLogic = new FundRequestBusinessLogic(); }
// GET: User public ActionResult Index() { ViewBag.Title = "Test Home"; var users = UserBusinessLogic.GetUsers(); return(View(users)); }
public ActionResult trenAnalysisByItems() { UserBusinessLogic BL = new UserBusinessLogic(); ViewBag.catalogue = BL.getAllCatalogue(); return(View()); }
private void btnDeleteUsers_Click(object sender, EventArgs e) { bool flag = false; if (selectedKeyIDList.Count == 0) { MessageBox.Show("请选择要删除的用户!"); } else { foreach (string userID in selectedKeyIDList) { UserBusinessLogic userBusinessLogic = new UserBusinessLogic(); flag = userBusinessLogic.DeleteUsersById(userID); } if (!flag) { MessageBox.Show("删除失败!"); } else { MessageBox.Show("删除成功!"); } } this.dgvUsers.DataSource = this.usersBindingSource; UserManageForm_Load(sender, e); selectedKeyIDList.Clear(); }
public ClientVisitController() { clientBusinessLogic = new ClientBusinessLogic(); userBusinessLogic = new UserBusinessLogic(); referenceBusinessLogic = new ReferenceBusinessLogic(); bsoBusinessLogic = new BSOBusinessLogic(); }
public Invitation ModelToEntity(OwnerInvitationModel model) { if (model == null) { return(null); } ApplicationUser acceptingAppUser = null; if (!string.IsNullOrEmpty(model.AcceptingUserId)) { var id = model.AcceptingUserId.Split('/').Last(); var guid = Guid.Parse(id); var acceptingUser = new UserBusinessLogic().GetUserEntityById(guid); acceptingAppUser = acceptingUser.AppUser; } return(new Invitation { Id = model.Id, SentTo = model.SentTo, AuthorizationCode = new InvitationAuthCode { EmailedTo = model.SentTo, InvitingTenancy = model.InvitingTenancy }, DateSent = DateTime.UtcNow, ExpirationTime = model.ExpirationTime, ResentTimes = 0, Status = model.Status, Tenancy = model.Tenancy, Role = model.Role, InvitingTenant = model.InvitingTenancy, AcceptingUser = acceptingAppUser }); }
public void UnfollowTeamTest() { var team = new Team() { Id = 0, Name = "Team", SportId = 1 }; var teamBL = new TeamBusinessLogic(mockTeamRepo.Object, NO_BUSINESS_LOGIC); var userBL = new UserBusinessLogic(mockUserRepo.Object, teamBL, mockUTRepo.Object); mockTeamRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(team); mockUserRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(userWithAllData); var fav = new UsersTeams { TeamId = team.Id, Team = team, User = userWithAllData, UserId = userWithAllData.Id }; mockUTRepo.Setup(r => r.Get(It.IsAny <Expression <Func <UsersTeams, bool> > >(), null, "")).Returns(new List <UsersTeams>() { fav }); userBL.FollowTeam(userWithAllData.Id, team.Id); userBL.UnfollowTeam(userWithAllData.Id, team.Id); mockUserRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.Exactly(2)); mockTeamRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.Exactly(2)); mockUTRepo.Verify(x => x.Delete(fav), Times.Once()); }
public UsersController() { userRepository = new EFUserRepository(); userBusinessLogic = new UserBusinessLogic(userRepository); groupRepository = new EFGroupRepository(); groupBusinessLogic = new GroupBusinessLogic(groupRepository); }
public bool Delete(UserBusinessLogic user) { bool isSuccess = false; SqlConnection con = new SqlConnection(myconnstring); try { string sql = "delete from Users where id=@id"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@id", user.id); con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { //Query successful isSuccess = true; } else { //Query failed isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } return(isSuccess); }
public ActionResult Login(LoginModel loggedinUser) { UserBusinessLogic _user = new UserBusinessLogic(); User foundUser = new User(); if (ModelState.IsValid) { foundUser.UserName = loggedinUser.Username; foundUser.Password = loggedinUser.Password; ResultUser _result = _user.checkingUserInDB(foundUser); if (_user.checkingUserInDB(foundUser) != null) { UserModel loggingUserIN = Mapping.Mapper.UserToUserModel(_result.User); Session["UserSession"] = loggingUserIN; return(RedirectToAction("Search", "Home")); } else { loggedinUser.DialogMessage = _result.Message; loggedinUser.DialogMessageType = _result.Type.ToString(); return(View(loggedinUser)); } } return(View(loggedinUser)); }
public UserInfoPrincipal(string userName) { UserBusinessLogic userLogic = new UserBusinessLogic(); var user = userLogic.GetUserInfoByUserName(userName); this.identity = new UserInfoIdentity(user.ID, user.UserName, user.IsAdmin); }
protected ControllerTests() { var mockPrincipal = new Mock <IBusinessLogicPrincipal>(); mockPrincipal.Setup(x => x.IsAllowed).Returns(true); mockPrincipal.Setup(x => x.IsAdmin).Returns(true); mockPrincipal.Setup(x => x.IsVerwalter).Returns(false); mockPrincipal.Setup(x => x.CurrentUid).Returns("if15b032"); var abl = new AccessoryBusinessLogic(Dal, mockPrincipal.Object); var cbl = new CustomFieldsBusinessLogic(Dal, mockPrincipal.Object); var dbl = new DamageBusinessLogic(Dal, mockPrincipal.Object); var debl = new DeviceBusinessLogic(Dal, mockPrincipal.Object); var blbl = new BusinessLogic.BusinessLogic(Dal, mockPrincipal.Object); var obl = new OrderBusinessLogic(Dal, mockPrincipal.Object); var sbl = new SettingBusinessLogic(Dal, mockPrincipal.Object); var ubl = new UserBusinessLogic(Dal, mockPrincipal.Object); Bl = new BusinessLogicFacade(Dal, blbl, abl, cbl, dbl, debl, obl, sbl, ubl); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); var subject = new ClaimsIdentity("Federation", ClaimTypes.Name, ClaimTypes.Role); subject.AddClaim(new Claim(ClaimTypes.Role, "Admin", ClaimValueTypes.String)); subject.AddClaim(new Claim(ClaimTypes.Name, "if15b032", ClaimValueTypes.String)); _controllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(subject) } }; }
private void btnLogin_Click(object sender, EventArgs e) { Users user = new Users(); string username = txbUserName.Text.Trim(); string password = txbPassword.Text.Trim(); UserBusinessLogic usersLogicBusiness = new UserBusinessLogic(); user = usersLogicBusiness.GetUsersByUsername(username); if (user == null) { MessageBox.Show("该用户不存在!"); } else { byte[] input = Encoding.Default.GetBytes(this.txbPassword.Text.Trim()); MD5 md5 = new MD5CryptoServiceProvider(); byte[] output = md5.ComputeHash(input); password = BitConverter.ToString(output).Replace("-", ""); if (user.Password == password) { this.Hide(); MainForm mainForm = new MainForm(user.UserID, this); mainForm.Show(); } else { MessageBox.Show("密码不正确,请重新输入!"); } } }
public void Startup() { userRepository = new MockUserRepository(); userBusinessLogic = new UserBusinessLogic(userRepository); groupRepository = new MockGroupRepository(); groupBusinessLogic = new GroupBusinessLogic(groupRepository); }
public void CreateUserBL_WithParameters_Ok() { IUserDataAccess userDataAccess = new UserDataAccess(); IUserBusinessLogic userBL = new UserBusinessLogic(userDataAccess); Assert.IsNotNull(userBL); }
public ActionResult ForgotPassword(ForgotPasswordUser forgotPasswordUser) { var appUserContactEmail = forgotPasswordUser.ContactEmail; var _userBusinessLogic = new UserBusinessLogic(); var invitationManager = new InvitationManager(); if (!string.IsNullOrEmpty(appUserContactEmail)) { try { var valid = Regex.IsMatch(appUserContactEmail, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase); if (!valid) { TempData.Remove("EmailAddressError"); TempData.Add("EmailAddressError", "Please use a valid email address."); return(View("ForgotPassword")); } var currentUrl = Request.Url; var user = _userBusinessLogic.GetByEmail(appUserContactEmail); bool sent = false; if (user != null) { //Session["appUser"] = user.AppUser; var applicationUser = user.AppUser; sent = _userBusinessLogic.SendResetPasswordEmail( applicationUser.ContactEmail, applicationUser.PrincipalId, currentUrl, applicationUser.Tenancy); return(RedirectToAction(sent ? "ForgotEmailSendConfirmation" : "ForgotPassword")); } var systemOwner = _userBusinessLogic.GetSuperAdmin(appUserContactEmail); if (systemOwner != null) { //Session["appUser"] = systemOwner; sent = _userBusinessLogic.SendResetPasswordEmail( systemOwner.ContactEmail, systemOwner.PrincipalId, currentUrl, systemOwner.Tenancy); return(RedirectToAction(sent ? "ForgotEmailSendConfirmation" : "ForgotPassword")); } } catch (Exception ex) { TempData.Add("EmailAddressError", "The email was not sent, please contact the system administrator."); var message = ExceptionHandler.Manage(ex, this, Layer.UILogic) ? ex.Message : "An unexpected error has ocurred."; ModelState.AddModelError("ContactEmail", message); return(View("ForgotPassword")); } TempData.Remove("EmailAddressError"); TempData.Add("EmailAddressError", "The email address does not exist!."); ModelState.AddModelError("ContactEmail", "The email address does not exist!"); return(View("ForgotPassword")); } TempData.Remove("EmailAddressError"); TempData.Add("EmailAddressError", "Please the email address is required."); ModelState.AddModelError("ContactEmail", "Please the email address is required"); return(View("ForgotPassword")); }
public Report2() { InitializeComponent(); userBusinessLogic = new UserBusinessLogic(new UserDataAccess()); auditLogBussinesLogic = new AuditLogBussinesLogic(new AuditLogDataAccess()); usersForReport = new List <string>(); report = new Dictionary <String, Dictionary <DateTime, int> >(); Refresh(); }
public ReportForm() { InitializeComponent(); userBusinessLogic = new UserBusinessLogic(new UserDataAccess()); auditLogBussinesLogic = new AuditLogBussinesLogic(new AuditLogDataAccess()); usersForReport = new List <string>(); LoadComboBox(); Refresh(); }
public ActionResult Index2() { EfRepoContext efRepoContext = new EfRepoContext(); UserRepository userRepository = new UserRepository(efRepoContext); UserBusinessLogic ubl = new UserBusinessLogic(efRepoContext, userRepository); var a = ubl.GetAllUsers(); ViewBag.ContextID = efRepoContext.Id; return(View("Index", a)); }
public MainForm() { InitializeComponent(); _supplierBusinessLogic = new SupplierBusinessLogic(); _productBusinessLogic = new ProductBusinessLogic(); _userBusinessLogic = new UserBusinessLogic(); _billBusinessLogic = new BillBusinessLogic(); _shipperBusinessLogic = new ShipperBussinessLogic(); _productTypeBusinessLogic = new ProductTypeBusinessLogic(); _importBusinessLogic = new ImportBusinessLogic(); }
public ActionResult Delete(string id) { if (UserBusinessLogic.getInstance().DeleteUser(id) == -1) { TempData["Success"] = "User was successfully deleted"; } else { TempData["Error"] = "User was unsuccessfully deleted"; } return(RedirectToAction("Index")); }
public ActionResult Edit(sp_UserSelect_Result model) { if (UserBusinessLogic.getInstance().UpdateUser(model) == -1) { TempData["Success"] = "User was successfully updated"; } else { TempData["Error"] = "User was unsuccessfully updated"; } return(RedirectToAction("Index")); }
public void FollowTeamTest() { var team = new Team(); var teamBL = new TeamBusinessLogic(mockTeamRepo.Object, NO_BUSINESS_LOGIC); var userBL = new UserBusinessLogic(mockUserRepo.Object, teamBL, mockUTRepo.Object); mockTeamRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(team); mockUserRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(userWithAllData); userBL.FollowTeam(userWithAllData.Id, team.Id); mockUserRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.AtLeastOnce); mockTeamRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.Once); }
public ServiceResult <AdminLoginResponseModel> Login(LoginRequestModel model) { var response = UserBusinessLogic.Login(model.Email, model.Password); if (response.Success && !response.Value.IsSuper) { var userRoles = RoleMapBusinessLogic.FindBy(x => x.UserId == response.Value.UserId).Value.Select(x => x.RoleId).ToList(); response.Value.Roles = RoleDefinitionBusinessLogic.FindBy(x => userRoles.Contains(x.RoleId)).Value.ToList(); } return(response); }
public void UnfollowTeamShouldReturnExceptionTest() { var team = new Team(); var teamBL = new TeamBusinessLogic(mockTeamRepo.Object, NO_BUSINESS_LOGIC); var userBL = new UserBusinessLogic(mockUserRepo.Object, teamBL, mockUTRepo.Object); mockTeamRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(team); mockUserRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(userWithAllData); userBL.UnfollowTeam(userWithAllData.Id, 123); mockUserRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.Once()); mockTeamRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.Once()); mockUTRepo.Verify(x => x.Delete(It.IsAny <int>()), Times.Once()); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); await this.UserManager.AddToRoleAsync(user.Id, model.UserRoles); Inventory i = new Inventory(); UserBusinessLogic userlogic = new UserBusinessLogic(); string dept = userlogic.getUserByUsername(loggedinUsername).DepartmentID; string userType = model.UserRoles; AspNetUsers newUser = i.AspNetUsers.Where(x => x.Id == user.Id).First(); newUser.DepartmentID = dept; newUser.UserType = userType; i.SaveChanges(); return(RedirectToAction("ApproveOrReject", "DepManager")); } Inventory inv = new Inventory(); UserBusinessLogic userlogic1 = new UserBusinessLogic(); string dept1 = userlogic1.getUserByUsername(loggedinUsername).DepartmentID; if (dept1.Substring(0, 4) == "STOR") { ViewBag.Roles = new SelectList(inv.AspNetRoles.Where(x => x.Name.Substring(0, 4) == "Stor").ToList(), "Name", "Name"); } else { ViewBag.Roles = new SelectList(inv.AspNetRoles.Where(u => u.Name.Contains("DeptStaff")) .ToList(), "Name", "Name"); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
protected void buttonSignup_Click(object sender, EventArgs e) { User aUser = new User(); aUser.UserName = textBoxUserName.Text; aUser.Password = textBoxPassword.Text; aUser.Name = textBoxName.Text; aUser.Email = textBoxEmail.Text; UserBusinessLogic aUserBusinessLogic = new UserBusinessLogic(); lblMsg.ForeColor = Color.Green; lblMsg.Text = aUserBusinessLogic.addUser(aUser); Response.Redirect("SignIn.aspx"); }
public IHttpActionResult Get([FromUri] string username) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic); User user = UserBusinessLogic.GetUser(username); return(Ok(UserModel.ToModel(user))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult Delete([FromUri] string username) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic); UserBusinessLogic.DeleteUser(username); return(Ok("User deleted")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult Post([FromBody] UserModel userModel) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); Utils.HasAdminPermissions(Request, AuthorizationBusinessLogic); UserBusinessLogic.AddUser(userModel.ToEntity()); return(Ok("User added")); } catch (Exception e) { return(BadRequest(e.Message)); } }