public User Get(decimal document, string password) { User user = new User(); user.Document = document; user.Password = password; return Get<User>("UserValidate", user); }
public Project CreateProject(User u, List<ProjectElement> projectElements) { Project project = new Project() { isActive = true, dateModified = DateTime.Now }; project.projectElements = projectElements; try { User user = new User { id = u.id }; if (u.projects == null) { user.projects = new List<Project>(); } else { user.projects = u.projects; } VestnDB db = new VestnDB(); user.projects.Add(project); db.projects.Add(project); db.users.Attach(user); db.SaveChanges(); } catch (Exception e) { logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); return null; } return project; }
public MembershipUser CreateUser(RegisterViewModel viewModel)//string email, string password { MembershipUser membershipUser = GetUser(viewModel.Email, false); if (membershipUser != null) { return null; } var user = new User { UserName = viewModel.FirstName, UserSurname = viewModel.LastName, UserEmail = viewModel.Email, UserPassword = Crypto.HashPassword(viewModel.Password), UserBirthDate = viewModel.Birthday, }; var role = RoleService.GetAllRoles().FirstOrDefault(r => r.RoleName == "user"); if (role != null) { user.Roles.Add(role); } UserService.AddUser(user); membershipUser = GetUser(viewModel.Email, false); return membershipUser; }
protected void BtnLogin_Click(object sender, EventArgs e) { var user = new Entity.User(); if (txtName.Value == "") { Response.Write("<script>alert('账号不能为空!');</script>"); return; } if (txtPwd.Value == "") { Response.Write("<script>alert('密码不能为空!');</script>"); return; } user.UserId = txtName.Value; user.PassWord = txtPwd.Value; var systemManage = new UserManage(); user = systemManage.Login(user); if (user == null) { Response.Write("<script>alert('账号或密码错误,请重新输入!');</script>"); } else { Session["UserInfo"] = user; } }
public IList <Entity.User> QueryUserbll(Entity.User user) { Factory.Factory QueryUserFac = new Factory.Factory(); IDal.IQueryUser QueryUser = QueryUserFac.QueryUser(); IList <Entity.User> LUser = QueryUser.select(user); return(LUser); }
public List<Entity.User> GetUsers(string id) { UserBO userBO = new UserBO(); Entity.User user = new Entity.User(); user.CompanyId = id; user.Name = string.Empty; return userBO.List(user); }
public bool ActivateUser(User user, bool toActivate) { MembershipUser membershipUser = Membership.GetUser(user.userName); membershipUser.IsApproved = toActivate; Membership.UpdateUser(membershipUser); membershipUser = Membership.GetUser(user.userName); return membershipUser.IsApproved; }
/// <summary> /// 获取你的赠赠卡 /// </summary> /// <returns></returns> public async Task <ActionResult> Index() { string code = Request["code"]; string openid = ""; //并非回调回来 if (string.IsNullOrEmpty(code))// { //判断是否有token,如果有的话,就认为其已经登录 string token = string.Empty; var tokenCookie = Request.Cookies.Get("token"); if (tokenCookie != null) { token = System.Web.HttpUtility.UrlDecode(tokenCookie.Value); openid = Cipher.Decrypt3DES(token); } openid = "om28r0QUuRtqZBaqOxzS0A4lEqTk"; if (string.IsNullOrEmpty(openid))//跳转授权页面 { string redirecturl = Request.Url.ToString(); string url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirecturl + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"; return(Redirect(url)); } //如果已经生成卡片,就跳转保存分享卡片页面 User user = new Entity.User(); if ((user = await userService.GetUser(openid, "")) != null) { string urlShare = "/Home/ShareCard"; return(Redirect(urlShare)); } //拿到openid,返回页面 ViewBag.OpenId = openid; return(View()); } //如果有code,则进行拿到openid,并生成token,放入cookies中,返回页面 var accessToken = await wechatService.GetWechatOpenId(code); if (accessToken == null) { //跳转错误页 } openid = accessToken.openid; string newtoken = Cipher.Encrypt3DES(accessToken.openid); HttpCookie cookies = new HttpCookie("token"); cookies.Domain = ".zengzenggift.xin"; cookies.Expires = DateTime.Now.AddDays(30); cookies.Value = HttpUtility.UrlEncode(newtoken); Response.SetCookie(cookies); ViewBag.OpenId = openid; return(View()); }
public User AddConnection(User u, int connection) { if (u.connections == null) { u.connections += connection; } else { u.connections = u.connections + "," + connection; } return UpdateUser(u); }
public async Task <ResponseModel <Pager <User> > > GetUserPage(UserSearchModel request) { ResponseModel <Pager <User> > result = new ResponseModel <Pager <Entity.User> >(); result.Code = 1; User user = new Entity.User() { ID = request.ID, Mobile = request.Mobile }; result.Data = await userService.GetUsers(user, request.PageCount, request.PageNumber); return(result); }
protected string SendMail(int id) { Entity.User newUser = new Entity.User(); DataAccess newDataAccess = new DataAccess(); newUser = newDataAccess.GetUser(id); string emailBodyText = Utilities.ReplaceTokens(HTMLEditor1.Text, newUser); emailBodyText = ReplaceImageSource(emailBodyText); string emailSubject = Utilities.ReplaceTokens(txtEmailSubject.Text, newUser); string message = MailHelper.SendMailMessage(txtFromEmail.Text, string.Empty, newUser.Email, string.Empty, string.Empty, emailSubject, emailBodyText, MailPriority.Normal); lblError.Text = message; return(message); }
/// <summary> /// Maps the user by crew. /// </summary> /// <param name="crewmember">The crewmember.</param> /// <returns>User object</returns> public static User MapUserByCrew(Crewmember crewmember) { User user = null; if (crewmember != null && crewmember.PersonalDetail != null) { user = new User(); user.FirstName = crewmember.PersonalDetail.FirstName; user.LastName = crewmember.PersonalDetail.LastName; user.MiddleName = crewmember.PersonalDetail.MiddleName; user.PersonId = crewmember.CrewmemberId; user.ImageAddress = crewmember.SecurityPhotoAddress; user.DepartmentId = crewmember.DepartmentId; } return user; }
protected string SendMail(Entity.User newUser, int emailContentID) { EmailDelivery emaildelivery = populateEmailDelivery(newUser, emailContentID); EmailDeliveryDAL emailDeliveryDAL = new EmailDeliveryDAL(); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); DateTime originalSchedule = emaildelivery.ScheduleTime; if (chkReschedule1.Checked == true) { emaildelivery.ScheduleTime = RescheduleTime(ddlReschedule1.SelectedValue, originalSchedule); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); } if (chkReschedule2.Checked == true) { emaildelivery.ScheduleTime = RescheduleTime(ddlReschedule2.SelectedValue, originalSchedule); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); } if (chkReschedule3.Checked == true) { emaildelivery.ScheduleTime = RescheduleTime(ddlReschedule3.SelectedValue, originalSchedule); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); } if (chkReschedule4.Checked == true) { emaildelivery.ScheduleTime = RescheduleTime(ddlReschedule4.SelectedValue, originalSchedule); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); } if (chkReschedule5.Checked == true) { emaildelivery.ScheduleTime = RescheduleTime(ddlReschedule5.SelectedValue, originalSchedule); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); } if (chkReschedule6.Checked == true) { emaildelivery.ScheduleTime = RescheduleTime(ddlReschedule6.SelectedValue, originalSchedule); emailDeliveryDAL.SaveEmailDelivery(emaildelivery); } //string emailBodyText = Utilities.ReplaceTokens(HTMLEditor1.Text, newUser); //emailBodyText = ReplaceImageSource(emailBodyText); //string emailSubject = Utilities.ReplaceTokens(txtEmailSubject.Text, newUser); //string message = MailHelper.SendMailMessage(txtFromEmail.Text, txtReplytoEmail.Text, newUser.Email, string.Empty, string.Empty, emailSubject, emailBodyText, MailPriority.Normal); //return message; return(string.Empty); }
public void CreateMembershipUser(User user, string password) { //Membership logic MembershipCreateStatus createStatus; Membership.CreateUser(user.userName, password, user.email, null, null, false, null, out createStatus); if (createStatus != MembershipCreateStatus.Success) { } //Entity logic try { VestnDB db = new VestnDB(); //if (user.willingToRelocate == null) //{ // user.willingToRelocate = WillingToRelocateType.undecided; //} if (user.projects == null) { user.projects = new List<Project>(); } if (user.birthDate.Year < 1800) { user.birthDate = new DateTime(1800, 1, 1); } if (user.graduationDate.Year < 1800) { user.graduationDate = new DateTime(1800, 1, 1); } db.users.Add(user); db.SaveChanges(); //fill with projects fillProjects(user); } catch (InvalidOperationException) { //If the entity logic failed, delete the stray MemershipUser Membership.DeleteUser(user.userName); //cant log errors here because of circular dependence } }
public void AddProjectIdToOrder(int newProjectId, User user) { try { VestnDB db = new VestnDB(); User u = new User { id = user.id }; db.users.Attach(u); u.projectOrder = user.projectOrder; if (u.projectOrder == null) { List<int> currentProjects = new List<int>(); string newProjectOrder = null; foreach (Project p in user.projects) { if (p.isActive == true && p.privacy != "deleted") { currentProjects.Add(p.id); } } foreach (int y in currentProjects) { newProjectOrder += y + " "; } newProjectOrder = newProjectOrder.TrimEnd().Replace(' ', ','); u.projectOrder = newProjectOrder; user.projectOrder = newProjectOrder; } else { u.projectOrder = newProjectId.ToString() + "," + u.projectOrder; user.projectOrder = newProjectId.ToString() + "," + user.projectOrder; //u.projectOrder += ("," + newProjectId.ToString()); //user.projectOrder += ("," + newProjectId.ToString()); } db.SaveChanges(); } catch (Exception ex) { } }
public decimal Save(int rol, decimal document, string name, string password) { CultureInfo ci = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; int id = int.Parse(Session[sessionName].ToString()); UserBO userBO = new UserBO(); User currentUser = userBO.Get(id); Entity.User user = new Entity.User(); user.Document = document; user.Name = name; user.Password = password; user.RolId = rol; user.CompanyId = currentUser.CompanyId; userBO.Save(user); return user.Document; }
public bool AddNetworkUser(int networkId, int userId) { try { VestnDB db = new VestnDB(); var n = new Network { id = networkId }; var u = new User { id = userId }; db.networks.Attach(n); db.users.Attach(u); n.networkUsers.Add(u); db.SaveChanges(); return true; } catch (Exception ex) { LogAccessor la = new LogAccessor(); la.CreateLog(DateTime.Now, "Network Accessor AddAdmin", ex.StackTrace); return false; } }
public List<User> List(User user) { return Execute<User>("UserList", user); }
public User toUser() { User newUser = new User(); newUser.firstName = this.firstName; newUser.lastName = this.lastName; newUser.title = this.title; newUser.email = this.email; newUser.userName = this.userName; newUser.id = this.id; newUser.birthDate = this.birthDate; newUser.location = this.location; newUser.organization = this.school; newUser.major = this.major; newUser.phoneNumber = this.phoneNumber; //newUser.willingToRelocate = this.willingToRelocate; newUser.emailVerified = this.emailVerified; newUser.isPublic = this.isPublic; newUser.isActive = this.isActive; newUser.profilePicture = this.profilePicture; newUser.profilePictureThumbnail = this.profilePictureThumbnail; newUser.aboutPicture = this.aboutPicture; newUser.aboutPictureThumbnail = this.aboutPictureThumbnail; newUser.profileURL = this.profileURL; newUser.projectOrder = this.projectOrder; return newUser; }
public int Delete(User user) { return ExecuteScalar("UserDelete", user); }
public RegisterModel(User user) { this.UserName = user.userName; this.Email = user.email; }
public UserModel(User user) { this.firstName = user.firstName; this.lastName = user.lastName; this.title = user.title; this.email = user.email; this.userName = user.userName; this.id = user.id; this.birthDate = user.birthDate; this.location = user.location; this.school = user.organization; this.major = user.major; this.phoneNumber = user.phoneNumber; //this.willingToRelocate = user.willingToRelocate; this.emailVerified = user.emailVerified; this.isPublic = user.isPublic; this.isActive = user.isActive; this.profilePicture = user.profilePicture; this.profilePictureThumbnail = user.profilePictureThumbnail; this.aboutPicture = user.aboutPicture; this.aboutPictureThumbnail = user.aboutPictureThumbnail; this.profileURL = user.profileURL; this.projectOrder = user.projectOrder; }
protected EmailDelivery populateEmailDelivery(Entity.User newUser, int emailContentID) { EmailDelivery emailDelivery = new EmailDelivery(); emailDelivery.UserID = newUser.UserID; emailDelivery.FromAddress = txtFromEmail.Text.Trim(); emailDelivery.ToAddress = newUser.Email; emailDelivery.CcAddress = string.Empty; emailDelivery.ReplyToAddress = txtReplytoEmail.Text.Trim(); emailDelivery.TemplateID = Convert.ToInt32(ddlSelectTemplate.SelectedValue); emailDelivery.EmailSubject = Utilities.ReplaceTokens(txtEmailSubject.Text, newUser); emailDelivery.EmailContentID = emailContentID; emailDelivery.NameToken = Utils.Utilities.UppercaseName(newUser.Name); emailDelivery.BdayToken = newUser.BirthDay.ToString("MMMM dd"); emailDelivery.ZipToken = newUser.ZipCode; emailDelivery.EmailToken = newUser.Email; if (rdbScheduleBy.SelectedValue.Equals("0")) { emailDelivery.ScheduleTime = System.DateTime.Now.AddMinutes(5.0); } else if (rdbScheduleBy.SelectedValue.Equals("1")) { DateTime deliveryDate = new DateTime(); _scheduleTime = string.Format("{0} {1}", txtScheduleDate.Text.Trim(), txtScheduleTime.Text.Trim()); DateTime.TryParse(_scheduleTime, out deliveryDate); emailDelivery.ScheduleTime = deliveryDate; } else if (rdbScheduleBy.SelectedValue.Equals("2")) { double hour = 0.0; double.TryParse(ddlScheduleToken.SelectedValue, out hour); if (newUser.BirthDay.Month == 2 && newUser.BirthDay.Day == 29 && !IsLeapYear(System.DateTime.Now.Year)) { _scheduleTime = string.Format("{0}/{1}/{2}", newUser.BirthDay.Month, newUser.BirthDay.Day - 1, System.DateTime.Now.Year); } else { _scheduleTime = string.Format("{0}/{1}/{2}", newUser.BirthDay.Month, newUser.BirthDay.Day, System.DateTime.Now.Year); } DateTime deliveryDate = Convert.ToDateTime(_scheduleTime); if (deliveryDate < System.DateTime.Now) { TimeSpan diffDate = System.DateTime.Now.Subtract(deliveryDate); if (diffDate.Days > 30) { deliveryDate = deliveryDate.AddYears(1); } } if (deliveryDate > System.DateTime.Now) { TimeSpan diffDate = deliveryDate.Subtract(System.DateTime.Now); if (diffDate.Days > 330) { deliveryDate = deliveryDate.AddYears(-1); } } deliveryDate = deliveryDate.AddHours(hour); emailDelivery.ScheduleTime = deliveryDate; } emailDelivery.Status = (int)Utils.Enum.Status.Pending; emailDelivery.Priority = Convert.ToInt32(ddlPriority.SelectedValue); return(emailDelivery); }
public ProfileModel(User user) { this.id = user.id; this.birthDate = user.birthDate; this.description = user.description; //this.status = user.status; this.graduationDate = user.graduationDate; this.email = user.email; this.firstName = user.firstName; this.lastName = user.lastName; this.title = user.title; this.location = user.location; this.major = user.major; this.phoneNumber = user.phoneNumber; this.school = user.organization; this.userName = user.userName; //this.willingToRelocate = user.willingToRelocate; this.profilePicture = user.profilePicture; this.profilePictureThumbnail = user.profilePictureThumbnail; this.aboutPicture = user.aboutPicture; this.aboutPictureThumbnail = user.aboutPictureThumbnail; this.projects = new List<ProjectModel>(); this.profileURL = user.profileURL; this.projectOrder = user.projectOrder; TagManager tm = new TagManager(); this.userTags = tm.getAllUserTags(this.id); if(user.projects != null) { foreach (Project project in user.projects) { if (project.isActive) { this.projects.Add(new ProjectModel(project)); } } } this.resume = user.resume; this.emailVerified = user.emailVerified; this.isPublic = user.isPublic; this.isActive = user.isActive; //this.visibleProject = "project0"; }
public void DeleteUser(User user) { context.Set<User>().Remove(user); }
public bool ValidateUser(User user, string password) { if (user != null) { if (Membership.ValidateUser(user.userName, password)) { return true; } } return false; }
public void AddUser(User user) { context.Set<User>().Add(user); }
public void UpdateUser(User user) { // context.Entry(user).State = System.Data.Entity.EntityState.Modified; var oldUser = GetUser(user.UserId); context.Entry(oldUser).CurrentValues.SetValues(user); }
public bool VerifyEmail(int userId) { try { VestnDB db = new VestnDB(); User u = new User { id = userId }; db.users.Attach(u); u.emailVerified = 1; db.SaveChanges(); return true; } catch (Exception ex) { return false; } }
public User VerifyUserEmail(User user, int toActivate) { user.emailVerified = toActivate; return UpdateUser(user); }
private void fillProjects(User u) { VestnDB vestnDB = new VestnDB(); Project project = new Project { name = "Test Project", description = "Test Description", }; //Project Elements ProjectElement_Information informationElement; ProjectElement_Experience experienceElement; ProjectElement_Document documentElement; ProjectElement_Video videoElement; ProjectElement_Picture pictureElement; List<ProjectElement> projectElements; informationElement = new ProjectElement_Information { location = "Here", email = "*****@*****.**", school= "Univeristy of Nebraska- Lincoln", phone = "402-402-4111", major = "Actuarial Science", minor = "Business Administration", description = "tetetetetet" }; documentElement = new ProjectElement_Document { description = "im a document", documentLocation = "asdfasdf" }; experienceElement = new ProjectElement_Experience { jobTitle = "Owner", description = "I'm CEO Bitch.", startDate = new DateTime(1991, 6, 12), endDate = new DateTime(2011, 6, 12) }; pictureElement = new ProjectElement_Picture { description = "im a picture", pictureLocation = "sadfsadfsa" }; videoElement = new ProjectElement_Video { //put a test id you know in here haun videoId = "xxxxx", description = "asdfsadfasdf" }; projectElements = new List<ProjectElement>(); projectElements.Add(informationElement); projectElements.Add(experienceElement); projectElements.Add(documentElement); projectElements.Add(pictureElement); projectElements.Add(videoElement); //Save elements to project project.projectElements = projectElements; //Save Changes to DB VestnDB db = new VestnDB(); db.projects.Add(project); if (u.projects == null) { u.projects = new List<Project>(); } u.projects.Add(project); db.Entry(u).State = EntityState.Modified; db.SaveChanges(); }
private User UpdateEntityUser(User user) { //Entity logic for username update try { VestnDB db = new VestnDB(); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { logAccessor.CreateLog(DateTime.Now, this.GetType().ToString() + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), e.ToString()); return null; } return user; }
public User Get(decimal document) { User user = new User(); user.Document = document; return Get<User>("UserGet", user); }
public int Insert(User user) { return ExecuteScalar("UserInsert", user); }
private void fillUsers() { VestnDB vestnDB = new VestnDB(); User user = new User { userName = "******", email = "*****@*****.**", firstName = "database", lastName = "test", birthDate = DateTime.Now, graduationDate = DateTime.Now.AddYears(1), tagIds = null, location = "Lincoln, Ne", organization = "Univeristy of Nebraska-Lincoln", major= "Testing", phoneNumber = "555-555-5555", //willingToRelocate = WillingToRelocateType.no, }; User user2 = new User { userName = "******", email = "*****@*****.**", firstName = "database2", lastName = "test2", birthDate = DateTime.Now, graduationDate = DateTime.Now.AddYears(1), tagIds = null, location = "Omaha, Ne", organization = "Univeristy of Nebraska-Omaha", major = "Testing2", phoneNumber = "222-222-2222", //willingToRelocate = WillingToRelocateType.yes, }; vestnDB.users.Add(user); vestnDB.users.Add(user2); vestnDB.SaveChanges(); fillProjects(user); fillProjects(user2); }
public int Update(User user) { return ExecuteScalar("UserUpdate", user); }
private void fillUsersWithMembership() { User user1 = new User { userName = "******", email = "*****@*****.**", firstName = "database", lastName = "test", birthDate = DateTime.Now, tagIds = null, location = "Lincoln, Ne", organization = "Univeristy of Nebraska-Lincoln", major = "Testing", phoneNumber = "555-555-5555", //willingToRelocate = WillingToRelocateType.no, }; User user2 = new User { userName = "******", email = "*****@*****.**", firstName = "database2", lastName = "test2", birthDate = DateTime.Now, tagIds = null, location = "Omaha, Ne", organization = "Univeristy of Nebraska-Omaha", major = "Testing2", phoneNumber = "222-222-2222", //willingToRelocate = WillingToRelocateType.yes, }; CreateMembershipUser(user1, "password!1"); CreateMembershipUser(user2, "password!1"); }