示例#1
0
        public void UpdateRankingForSpecificUser(aspnet_User user, int uid)
        {
            int NoAccepted = uvareq.GetUvaUserSolvedProblems(uid);
            Rank userRank;

            try
            {
                if ( user.Rank != null)
                {
                    user.Rank.Solved = NoAccepted;
                }
                else
                {

                    userRank = new Rank()
                    {
                        IdUser = user.UserId,
                        UvaUserName = user.UserName,
                        Solved = NoAccepted
                    };

                    modx.Ranks.InsertOnSubmit(userRank);

                }

                modx.SubmitChanges();
            }
            catch (NullReferenceException ex)
            {

            }
            //test if null then same solved
        }
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.aspnet_User = DatabaseHelper.GetSingle<aspnet_User, string>(DatabaseHelper.SubsystemEnum.User,
                    this.UserName, LinqQueries.CompiledQuery_GetUserFromUserName);

            return ActivityExecutionStatus.Closed;
        }
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            MembershipUser memUser = Membership.GetUser(this.UserGuid);

            //aspnet_User user = db.aspnet_Users.Single(u => u.LoweredUserName == this._UserName && u.ApplicationId == DatabaseHelper.ApplicationGuid);
            aspnet_User user = DatabaseHelper.GetSingle <aspnet_User, string>(DatabaseHelper.SubsystemEnum.User,
                                                                              memUser.UserName, LinqQueries.CompiledQuery_GetUserFromUserName);

            using (TransactionScope ts = new TransactionScope())
            {
                //update user email
                memUser.Email = this.NewEmail;
                Membership.UpdateUser(memUser);

                //update username
                if (!string.Equals(memUser.UserName, this.NewEmail))
                {
                    user.UserName        = this.NewEmail;
                    user.LoweredUserName = this.NewEmail.ToLower();
                }

                DatabaseHelper.UpdateObject <aspnet_User>(DatabaseHelper.SubsystemEnum.User,
                                                          user, null, null);

                ts.Complete();
            }

            return(ActivityExecutionStatus.Closed);
        }
示例#4
0
        public void UpdateSolutionsForSpecificUser(aspnet_User user, int uid)
        {
            foreach (var problem in modx.Problems)
            {
                var exists = user.Usuario.SolutionsPerUsers.Where(x => x.Problemid == problem.UvaProblemId).FirstOrDefault();
                if (exists == null)
                {
                    Boolean isSolved = uvareq.ProblemSolvedByUser(uid, problem.UvaProblemId);
                    if (isSolved)
                    {
                        SolutionsPerUser sol = new SolutionsPerUser()
                        {
                            Problemid = problem.UvaProblemId,
                            Uid = uid
                        };
                        modx.SolutionsPerUsers.InsertOnSubmit(sol);
                    }
                }
                else
                {

                }

            }

            modx.SubmitChanges();
        }
    public void NewProfile(string username, string fullname, string phone)
    {
        RedBloodDataContext db = new RedBloodDataContext();

        var users = from u in db.aspnet_Users
                    where u.UserName == username
                    select u;

        if (users.Count() != 1)
        {
            return;
        }

        aspnet_User user = users.First();

        aspnet_UserProfile user_profile = new aspnet_UserProfile();

        user_profile.UserID   = user.UserId;
        user_profile.Fullname = fullname;
        user_profile.Phone    = phone;

        if (user.aspnet_UserProfile == null)
        {
            db.aspnet_UserProfiles.InsertOnSubmit(user_profile);
            db.SubmitChanges();
        }
    }
示例#6
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.aspnet_User = DatabaseHelper.GetSingle <aspnet_User, string>(DatabaseHelper.SubsystemEnum.User,
                                                                              this.UserName, LinqQueries.CompiledQuery_GetUserFromUserName);

            return(ActivityExecutionStatus.Closed);
        }
        // GET api/Facility

        public IEnumerable <facilityDTO> Getfacilities()
        {
            Guid               id            = (Guid)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey;
            aspnet_User        user          = db.aspnet_Users.Single(u => u.UserName == HttpContext.Current.User.Identity.Name);
            List <facilityDTO> facility_list = new List <facilityDTO>();

            foreach (facility aFacility in db.facilities.Where(f => f.user_id == user.UserId))
            {
                facility_list.Add(aFacility.toDTO());
            }
            return(facility_list);
        }
示例#8
0
        public ActionResult SifreDegistir(aspnet_User user, string EskiSifre, string YeniSifre)
        {
            bool x = Membership.GetUser(user.UserName).ChangePassword(EskiSifre, YeniSifre);

            if (x)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("GirisYap"));
            }
            else
            {
                TempData["d"] = "Eski şifrenizi yanlış girdiniz !";
                return(View());
            }
        }
示例#9
0
        public ClientModel GetClientForUser(Guid userId)
        {
            ClientModel model = null;

            using (var tran = DataContext.Connection.BeginTransaction(IsolationLevel.ReadUncommitted))
            {
                DataContext.Transaction = tran;
                aspnet_User aspUser = DataContext.aspnet_Users.FirstOrDefault(user => user.UserId == userId);
                tran.Commit();
                if (aspUser != null && aspUser.ClientAssigments != null && aspUser.ClientAssigments.ClientId != null)
                {
                    model = ClientModelSelectExpression.Invoke(aspUser.ClientAssigments.Client);
                }
            }
            return(model);
        }
示例#10
0
 public void ActivateClientForUser(Guid userId)
 {
     using (var tran = DataContext.Connection.BeginTransaction(IsolationLevel.ReadUncommitted))
     {
         DataContext.Transaction = tran;
         aspnet_User aspUser = DataContext.aspnet_Users.FirstOrDefault(user => user.UserId == userId);
         tran.Commit();
         if (aspUser != null)
         {
             if (aspUser.ClientAssigments != null && aspUser.ClientAssigments.ClientId.HasValue && aspUser.ClientAssigments.Client.UserAssigments.Count == 1)
             {
                 ActivateClient(aspUser.ClientAssigments.ClientId.Value);
             }
         }
     }
 }
示例#11
0
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        EMRDataClassesDataContext Q = new EMRDataClassesDataContext();
        aspnet_User a = new aspnet_User();

        if (Roles.IsUserInRole(Login1.UserName, "Doctor"))
        {
            // System.Web.HttpContext.Current.User.Identity.Name;
            a = Q.aspnet_Users.Where(d => d.UserName == Login1.UserName).SingleOrDefault();
            Session["doct"] = a;
            Response.Redirect("~/Doctor/PersonalInfo/View_doctor_info.aspx");
        }
        else if (Roles.IsUserInRole(Login1.UserName, "AdminDoctor"))
        {
            a = Q.aspnet_Users.Where(d => d.UserName == Login1.UserName).SingleOrDefault();
            Session["admdoc"] = a;

            Response.Redirect("~/Admin_doctor/PersonalInfo/View_doctor_info.aspx");
        }
        else if (Roles.IsUserInRole(Login1.UserName, "Nurse"))
        {
            a             = Q.aspnet_Users.Where(d => d.UserName == Login1.UserName).SingleOrDefault();
            Session["nu"] = a;
            Response.Redirect("~/Nurse/PersonalInfo/Nurse_View_info.aspx");
        }
        else if (Roles.IsUserInRole(Login1.UserName, "Patient"))
        {
            a             = Q.aspnet_Users.Where(d => d.UserName == User.Identity.Name).SingleOrDefault();
            Session["pa"] = a;
            Response.Redirect("~/Patient/PersonalInfo/View_patient_info.aspx");
        }
        else if (Roles.IsUserInRole(Login1.UserName, "Pharmacist"))
        {
            a = Q.aspnet_Users.Where(d => d.UserName == User.Identity.Name).SingleOrDefault();
            Session["pha"] = a;

            Response.Redirect("~/Pharmacist/PersonalInfo/View_pharmacist_info.aspx");
        }
        else if (Roles.IsUserInRole(Login1.UserName, "Admin"))
        {
            Label1.Text = " Welcome Admin " + Login1.UserName;
        }
        else
        {
            Label1.Text = "Invalid Username or/and Password";
        }
    }
示例#12
0
        public void FillProperties()
        {
            var db = Current.DB;

            if (Current.UserID.HasValue)
            {
                var currentUser = Current.UserID.Value;
                if (currentUser == this.User1)
                {
                    OtherUser = db.aspnet_Users.Where(u => u.UserId == this.User2).SingleOrDefault();
                }
                else if (currentUser == this.User2)
                {
                    OtherUser = db.aspnet_Users.Where(u => u.UserId == this.User1).SingleOrDefault();
                }
            }
        }
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        UserProfileRepository userrepo = new UserProfileRepository();
        string      userid             = Request.QueryString["userid"].ToString();
        string      role = Request.QueryString["RoleName"].ToString();
        Guid        id   = new Guid(userid);
        aspnet_User user = userrepo.selectByUserID(id);

        Session["UserName"] = user.UserName;

        if (rbtnmusicstore.Checked)
        {
            Response.Redirect("~/MMSStoreService.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + userid + "&RoleName=" + role);
        }
        else
        {
            ImgChoose.Visible = true;
        }
    }
示例#14
0
        public void FillProperties()
        {
            var db           = Current.DB;
            var conversation = db.Conversations.Where(c => c.ConversationID == this.ConversationID).SingleOrDefault();

            Subject = conversation.Subject;
            if (Current.UserID.HasValue)
            {
                var currentUser = Current.UserID.Value;
                if (currentUser == SenderID)
                {
                    OtherUser = db.aspnet_Users.Where(u => u.UserId == ReceipientID).SingleOrDefault();
                }
                else if (currentUser == ReceipientID)
                {
                    OtherUser = db.aspnet_Users.Where(u => u.UserId == SenderID).SingleOrDefault();
                }
            }
        }
示例#15
0
 protected void btnLogin_Click1(object sender, EventArgs e)
 {
     if (userrepo.GetUsers(txtUserName.Text) == false)
     {
         lblmessage.Visible = true;
     }
     else
     {
         aspnet_User user = userrepo.selectByUserName(txtUserName.Text);
         username = user.UserName;
         if (Membership.ValidateUser(username, txtpassword.Text))
         {
             lblmessage.Visible = false;
             Response.Redirect("~/ChooseLayer.aspx?FullName=" + txtUserName.Text);
         }
         else
         {
             lblmessage.Visible = true;
         }
     }
 }
    public void UpdateProfile(string username, string fullname, string phone)
    {
        RedBloodDataContext db = new RedBloodDataContext();

        var users = from u in db.aspnet_Users
                    where u.UserName == username
                    select u;

        if (users.Count() != 1)
        {
            return;
        }

        aspnet_User user = users.First();

        if (user.aspnet_UserProfile != null)
        {
            user.aspnet_UserProfile.Fullname = fullname;
            user.aspnet_UserProfile.Phone    = phone;

            db.SubmitChanges();
        }
    }
 partial void Deleteaspnet_User(aspnet_User instance);
 partial void Insertaspnet_User(aspnet_User instance);
 partial void Updateaspnet_User(aspnet_User instance);
示例#20
0
 partial void Deleteaspnet_User(aspnet_User instance);
    protected void Page_Load(object sender, EventArgs e)
    {
        aspnet_User a = new aspnet_User();

        a = (aspnet_User)Session["admdoc"];

        a = Q.aspnet_Users.Where(d => d.UserId == a.UserId).SingleOrDefault();

        p = Q.PersonalInfos.Where(g => g.UserId == a.UserId).SingleOrDefault();


        x = Q.Doctors.Where(k => k.PersonalInfoId == p.Id).SingleOrDefault();



        //x.Id = 1;

        //x = Q.Doctors.Where(z => z.Id == x.Id).SingleOrDefault();
        //p = Q.PersonalInfos.Where(w => w.Id == x.PersonalInfoId).SingleOrDefault();


        Label24.Text = x.Id.ToString();
        Label25.Text = p.FirstName;
        Label26.Text = p.LastName;


        Label27.Text = p.Gender;


        Label28.Text = "" + p.DateOfBrith.Value.Year + "/" + p.DateOfBrith.Value.Month + "/" + p.DateOfBrith.Value.Day;


        //age culc
        DateTime birth = (DateTime)p.DateOfBrith;
        DateTime now   = DateTime.Now;
        int      age   = now.Year - birth.Year;

        Label45.Text = age.ToString();

        Label29.Text = p.BloodType;

        if (p.Address == "")
        {
            Label30.Text           = "N/A !";
            Label30.ForeColor      = System.Drawing.Color.Gray;
            Label30.Font.Underline = true;
            Label30.Font.Italic    = true;
        }
        else
        {
            Label30.Text = p.Address;
        }
        if (p.Note == "")
        {
            Label31.Text           = "N/A !";
            Label31.ForeColor      = System.Drawing.Color.Gray;
            Label31.Font.Underline = true;
            Label31.Font.Italic    = true;
        }
        else
        {
            Label31.Text = p.Note;
        }
        if (p.Phone == "")
        {
            Label32.Text           = "N/A !";
            Label32.ForeColor      = System.Drawing.Color.Gray;
            Label32.Font.Underline = true;
            Label32.Font.Italic    = true;
        }
        else
        {
            Label32.Text = p.Phone;
        }
        if (p.BusinessPhone == "")
        {
            Label33.Text           = "N/A !";
            Label33.ForeColor      = System.Drawing.Color.Gray;
            Label33.Font.Underline = true;
            Label33.Font.Italic    = true;
        }
        else
        {
            Label33.Text = p.BusinessPhone;
        }
        if (p.Mobile == "")
        {
            Label34.Text           = "N/A !";
            Label34.ForeColor      = System.Drawing.Color.Gray;
            Label34.Font.Underline = true;
            Label34.Font.Italic    = true;
        }
        else
        {
            Label34.Text = p.Mobile;
        }
        if (p.Fax == "")
        {
            Label35.Text           = "N/A !";
            Label35.ForeColor      = System.Drawing.Color.Gray;
            Label35.Font.Underline = true;
            Label35.Font.Italic    = true;
        }
        else
        {
            Label35.Text = p.Fax;
        }
        if (p.Email == "")
        {
            Label36.Text           = "N/A !";
            Label36.ForeColor      = System.Drawing.Color.Gray;
            Label36.Font.Underline = true;
            Label36.Font.Italic    = true;
        }
        else
        {
            Label36.Text = p.Email;
        }
        if (p.FacebookURL == "")
        {
            Label37.Text           = "N/A !";
            Label37.ForeColor      = System.Drawing.Color.Gray;
            Label37.Font.Underline = true;
            Label37.Font.Italic    = true;
        }
        else
        {
            Label37.Text = p.FacebookURL;
        }
        if (p.TwitterURL == "")
        {
            Label38.Text           = "N/A !";
            Label38.ForeColor      = System.Drawing.Color.Gray;
            Label38.Font.Underline = true;
            Label38.Font.Italic    = true;
        }
        else
        {
            Label38.Text = p.TwitterURL;
        }
        if (p.Image == "")
        {
            Image1.ImageUrl = "~/pics/default.jpg";
            //Label39.Text = "N/A !";
            //Label39.ForeColor = System.Drawing.Color.Gray;
            //Label39.Font.Underline = true;
            //Label39.Font.Italic = true;
        }
        else
        {
            //Label39.Text = p.Image;
            Image1.ImageUrl = p.Image;
        }

        if (x.Compertence == "")
        {
            Label41.Text           = "N/A !";
            Label41.ForeColor      = System.Drawing.Color.Gray;
            Label41.Font.Underline = true;
            Label41.Font.Italic    = true;
        }
        else
        {
            Label41.Text = x.Compertence;
        }
        if (x.Type == 0)
        {
            Label42.Text = "Admin Doctor";
        }
        else
        {
            Label42.Text = "Doctor";
        }
    }
示例#22
0
 partial void Insertaspnet_User(aspnet_User instance);
示例#23
0
 partial void Updateaspnet_User(aspnet_User instance);
示例#24
0
 public void AddToaspnet_Users(aspnet_User aspnet_User)
 {
     base.AddObject("aspnet_Users", aspnet_User);
 }
示例#25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        aspnet_User a = new aspnet_User();

        a = (aspnet_User)Session["pa"];

        a = Q.aspnet_Users.Where(d => d.UserId == a.UserId).SingleOrDefault();

        p = Q.PersonalInfos.Where(g => g.UserId == a.UserId).SingleOrDefault();


        x = Q.Patients.Where(k => k.PersonalInfoId == p.Id).SingleOrDefault();

        //Q.Patients.Where(x => x.Id == 5).SingleOrDefault();
        //x = Q.Patients.Where(z => z.Id == 1).SingleOrDefault();
        //p = Q.PersonalInfos.Where(w => w.Id == 8).SingleOrDefault();

        // Q.PersonalInfos.Where();
        //  d = (Doctor)Session["doctor"];
        //x = (Patient)Session["pateint"];

        //x = Q.Patients.Where(z => z.Id == x.Id).SingleOrDefault();
        // p = Q.PersonalInfos.Where(w => w.Id == x.PersonalInfoId).SingleOrDefault();


        Label24.Text = x.Id.ToString();
        Label25.Text = x.PersonalInfo.FirstName;
        Label26.Text = x.PersonalInfo.LastName;

        DateTime birth = (DateTime)x.PersonalInfo.DateOfBrith;
        DateTime now   = DateTime.Now;
        int      age   = now.Year - birth.Year;

        Label45.Text = age.ToString();


        Label27.Text = x.PersonalInfo.Gender;


        Label28.Text = "" + x.PersonalInfo.DateOfBrith.Value.Year + "/" + x.PersonalInfo.DateOfBrith.Value.Month + "/" + x.PersonalInfo.DateOfBrith.Value.Day;


        Label29.Text = x.PersonalInfo.BloodType;

        if (x.PersonalInfo.Address == "")
        {
            Label30.Text           = "N/A !";
            Label30.ForeColor      = System.Drawing.Color.Gray;
            Label30.Font.Underline = true;
            Label30.Font.Italic    = true;
        }
        else
        {
            Label30.Text = x.PersonalInfo.Address;
        }
        if (x.PersonalInfo.Note == "")
        {
            Label31.Text           = "N/A !";
            Label31.ForeColor      = System.Drawing.Color.Gray;
            Label31.Font.Underline = true;
            Label31.Font.Italic    = true;
        }
        else
        {
            Label31.Text = x.PersonalInfo.Note;
        }
        if (x.PersonalInfo.Phone == "")
        {
            Label31.Text           = "N/A !";
            Label32.ForeColor      = System.Drawing.Color.Gray;
            Label32.Font.Underline = true;
            Label32.Font.Italic    = true;
        }
        else
        {
            Label32.Text = x.PersonalInfo.Phone;
        }
        if (x.PersonalInfo.BusinessPhone == "")
        {
            Label33.Text           = "N/A !";
            Label33.ForeColor      = System.Drawing.Color.Gray;
            Label33.Font.Underline = true;
            Label33.Font.Italic    = true;
        }
        else
        {
            Label33.Text = x.PersonalInfo.BusinessPhone;
        }
        if (x.PersonalInfo.Mobile == "")
        {
            Label34.Text           = "N/A !";
            Label34.ForeColor      = System.Drawing.Color.Gray;
            Label34.Font.Underline = true;
            Label34.Font.Italic    = true;
        }
        else
        {
            Label34.Text = x.PersonalInfo.Mobile;
        }
        if (x.PersonalInfo.Fax == "")
        {
            Label35.Text           = "N/A !";
            Label35.ForeColor      = System.Drawing.Color.Gray;
            Label35.Font.Underline = true;
            Label35.Font.Italic    = true;
        }
        else
        {
            Label35.Text = x.PersonalInfo.Fax;
        }
        if (x.PersonalInfo.Email == "")
        {
            Label36.Text           = "N/A !";
            Label36.ForeColor      = System.Drawing.Color.Gray;
            Label36.Font.Underline = true;
            Label36.Font.Italic    = true;
        }
        else
        {
            Label36.Text = x.PersonalInfo.Email;
        }
        if (x.PersonalInfo.FacebookURL == "")
        {
            Label37.Text           = "N/A !";
            Label37.ForeColor      = System.Drawing.Color.Gray;
            Label37.Font.Underline = true;
            Label37.Font.Italic    = true;
        }
        else
        {
            Label37.Text = x.PersonalInfo.FacebookURL;
        }
        if (x.PersonalInfo.TwitterURL == "")
        {
            Label38.Text           = "N/A !";
            Label38.ForeColor      = System.Drawing.Color.Gray;
            Label38.Font.Underline = true;
            Label38.Font.Italic    = true;
        }
        else
        {
            Label38.Text = x.PersonalInfo.TwitterURL;
        }
        if (x.PersonalInfo.Image == "")
        {
            Image1.ImageUrl = "~/pics/default.jpg";
            //    Label39.Text = "N/A !";
            //    Label39.ForeColor = System.Drawing.Color.Gray;
            //    Label39.Font.Underline = true;
            //    Label39.Font.Italic = true;
        }
        else
        {
            // Label39.Text = p.Image;
            Image1.ImageUrl = x.PersonalInfo.Image;
        }



        //Image1.ImageUrl = p.Image.Contains(Server.MapPath("~/pics/" + p.Id + ".png"));
    }
示例#26
0
 public void AddUser(aspnet_User tbluserprofile)
 {
     db.aspnet_Users.InsertOnSubmit(tbluserprofile);
 }
示例#27
0
 public static aspnet_User Createaspnet_User(global::System.Guid userId, string userName, string loweredUserName, bool isAnonymous, global::System.DateTime lastActivityDate, global::System.Guid applicationId)
 {
     aspnet_User aspnet_User = new aspnet_User();
     aspnet_User.UserId = userId;
     aspnet_User.UserName = userName;
     aspnet_User.LoweredUserName = loweredUserName;
     aspnet_User.IsAnonymous = isAnonymous;
     aspnet_User.LastActivityDate = lastActivityDate;
     aspnet_User.ApplicationId = applicationId;
     return aspnet_User;
 }
示例#28
0
	private void detach_aspnet_Users(aspnet_User entity)
	{
		this.SendPropertyChanging();
		entity.aspnet_Application = null;
	}
示例#29
0
文件: ChatModels.cs 项目: ringe/JoMAR
        public MyRoom(aspnet_User user, JodADataContext db)
        {
            Users = db.aspnet_Users.Select(x => new SelectListItem
            {
                Text = x.UserName,
                Value = x.UserId.ToString()
            }).ToList();

            Memberships = (from room in db.ChatRooms
                     join m2m in db.UserRooms on room.RoomID equals m2m.RoomID
                     where m2m.UserID == user.UserId
                     select room).ToList();

            MyRooms = user.ChatRooms;
            foreach (ChatRoom room in MyRooms)
                Memberships.Remove(room);
        }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        username = Request.QueryString["FullName"].ToString();
        aspnet_User user1 = userrepo.selectByUserName(username);

        if (rbtnArtist.Checked)
        {
            aspnet_User user      = userrepo.selectByUserName(username + "a");
            Artist      tblartist = new ArtistRepository().selectbyUserID(user1.UserId);

            if (user != null)
            {
                username            = user.UserName;
                userID              = user.UserId;
                Session["userid"]   = userID;
                Session["UserName"] = username;
                Session["RoleName"] = "Artist";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + userID + "&RoleName=" + "Artist");
                Session.Clear();
            }
            else if (tblartist != null)
            {
                Session["userid"]   = user1.UserId;
                Session["UserName"] = user1.UserName;
                Session["RoleName"] = "Artist";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + user1.UserId + "&RoleName=" + "Artist");
                Session.Clear();
            }
            else
            {
                lblMessage.Text = username + " doesn't have artist layer ";
            }
        }

        if (rbtnComposer.Checked)
        {
            aspnet_User user        = userrepo.selectByUserName(username + "c");
            Composer    tblcomposer = new ComposerRepository().selectbyUserID(user1.UserId);

            if (user != null)
            {
                username            = user.UserName;
                userID              = user.UserId;
                Session["userid"]   = userID;
                Session["UserName"] = username;
                Session["RoleName"] = "Composer";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + userID + "&RoleName=" + "Composer");
                Session.Clear();
            }
            else if (tblcomposer != null)
            {
                Session["userid"]   = user1.UserId;
                Session["UserName"] = user1.UserName;
                Session["RoleName"] = "Composer";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + user1.UserId + "&RoleName=" + "Composer");
                Session.Clear();
            }
            else
            {
                lblMessage.Text = username + " doesn't have  composer layer ";
            }
        }

        if (rbtnProducer.Checked)
        {
            aspnet_User user        = userrepo.selectByUserName(username + "p");
            Producer    tblproducer = new ProducerRepository().selectbyUserID(user1.UserId);

            if (user != null)
            {
                username            = user.UserName;
                userID              = user.UserId;
                Session["userid"]   = userID;
                Session["UserName"] = username;
                Session["RoleName"] = "Producer";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + userID + "&RoleName=" + "Producer");
                Session.Clear();
            }
            else if (tblproducer != null)
            {
                Session["userid"]   = user1.UserId;
                Session["UserName"] = user1.UserName;
                Session["RoleName"] = "Producer";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + user1.UserId + "&RoleName=" + "Producer");
                Session.Clear();
            }

            else
            {
                lblMessage.Text = username + " doesn't have producer layer ";
            }
        }
        if (rbtnBand.Checked)
        {
            aspnet_User user    = userrepo.selectByUserName(username + "b");
            Band        tblband = new BandRepository().selectbyUserID(user1.UserId);

            if (user != null)
            {
                username            = user.UserName;
                userID              = user.UserId;
                Session["userid"]   = userID;
                Session["UserName"] = username;
                Session["RoleName"] = "Band";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + userID + "&RoleName=" + "Band");
                Session.Clear();
            }
            else if (tblband != null)
            {
                Session["userid"]   = user1.UserId;
                Session["UserName"] = user1.UserName;
                Session["RoleName"] = "Band";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + user1.UserId + "&RoleName=" + "Band");
                Session.Clear();
            }
            else
            {
                lblMessage.Text = username + " doesn't have band layer ";
            }
        }
        if (rbtnStudio.Checked)
        {
            aspnet_User user      = userrepo.selectByUserName(username + "d");
            Studio      tblstudio = new StudioRepository().selectbyUserID(user1.UserId);

            if (user != null)
            {
                username            = user.UserName;
                userID              = user.UserId;
                Session["userid"]   = userID;
                Session["UserName"] = username;
                Session["RoleName"] = "Studio";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + userID + "&RoleName=" + "Studio");
                Session.Clear();
            }
            else if (tblstudio != null)
            {
                Session["userid"]   = user1.UserId;
                Session["UserName"] = user1.UserName;
                Session["RoleName"] = "Studio";
                Response.Redirect("~/SummaryReport.aspx?FullName=" + Request.QueryString["FullName"].ToString() + "&userid=" + user1.UserId + "&RoleName=" + "Studio");
                Session.Clear();
            }

            else
            {
                lblMessage.Text = username + " doesn't have studio layer ";
            }
        }
        else
        {
            // ImgChoose.Visible = true;
        }
    }
	private void detach_aspnet_Users(aspnet_User entity)
	{
		this.SendPropertyChanging();
		entity.Subscription = null;
	}
示例#32
0
        public void MakeMatch(aspnet_User one, aspnet_User two)
        {
            // Compute
            var totalNumQuestions = db.Questions.Count();
            int scoreSame         = 0;

            foreach (var q in db.Questions)
            {
                try
                {
                    var ansone = db.Responses.Where(u => u.UserId == one.UserId && u.QuestionId == q.Id).SingleOrDefault().AnswerId;
                    var anstwo = db.Responses.Where(u => u.UserId == two.UserId && u.QuestionId == q.Id).SingleOrDefault().AnswerId;
                    if (ansone == anstwo)
                    {
                        scoreSame++;
                    }
                }
                catch (NullReferenceException e)
                {
                    // If there was an error above, that means that one of them didn't answer the question because SingleOrDefault() returned null
                    // They can't answer only some of the questions and not the rest, so we don't need to check other questions
                    break; // keep scoreSame at 0, don't check other questions
                }
                catch
                {
                    // Other exception... uh, idk. Let it continue.
                }
            }
            var ratio = ((double)scoreSame) / totalNumQuestions;

            // Add noise
            var noiseInt = new Random().Next(1, 10); // 1% to 10% noise

            if (new Random().Next(0, 1) == 1)
            {
                noiseInt *= -1; // add or subtract
            }
            double noise = (double)noiseInt / 100;

            if (ratio + noise > 1 || ratio + noise < 0) // we want to limit to between 0 and 1
            {
                noise *= -1;
            }
            ratio += noise;

            // Get profiles
            var profile1 = AccountProfile.GetProfileOfUser(one.UserName);
            var profile2 = AccountProfile.GetProfileOfUser(two.UserName);

            // Write to DB
            var time = DateTime.Now;

            var m_one = new Match();

            m_one.RequestUser        = one.UserId;
            m_one.MatchedUser        = two.UserId;
            m_one.MatchedSex         = (profile2.Sex == 2);
            m_one.AreSameGrade       = profile1.Grade == profile2.Grade;
            m_one.CompatibilityIndex = ratio;
            m_one.DateCalculated     = time;

            db.Matches.InsertOnSubmit(m_one);

            var m_two = new Match();

            m_two.RequestUser        = two.UserId;
            m_two.MatchedUser        = one.UserId;
            m_two.MatchedSex         = (profile1.Sex == 2);
            m_two.AreSameGrade       = profile1.Grade == profile2.Grade;
            m_two.CompatibilityIndex = ratio;
            m_two.DateCalculated     = time;

            db.Matches.InsertOnSubmit(m_two);

            db.SubmitChanges();
        }