コード例 #1
0
        private void Review(HttpContext context)
        {
            string answer   = context.Request.Params["ans"];
            string question = context.Request.Params["ques"];
            int    bimid    = int.Parse(context.Request.Params["bimid"]);

            PindexProd.dbml.Review review = GetPindexProdContext2.Review.FirstOrDefault(o => o.BIMID == bimid && (o.UserID == Common.UserID || o.SessionID == Common.SessionID));
            if (review == null)
            {
                review           = new PindexProd.dbml.Review();
                review.Answer    = answer;
                review.BIMID     = bimid;
                review.Question  = question;
                review.UserID    = Common.UserID;
                review.SessionID = Common.SessionID;
                GetPindexProdContext2.Review.InsertOnSubmit(review);
                if (Common.UserID.HasValue)
                {
                    GetPindexProdContext1.Update(new POCOS.AppUser()
                    {
                        ID = Common.UserID.Value, Points = Common.Points
                    }, new[] { "Points" });
                }
            }
            else
            {
                review.Answer   = answer;
                review.Question = question;
            }
            GetPindexProdContext2.SubmitChanges();
            var q = from o in GetPindexProdContext2.Review where (o.UserID == Common.UserID || o.SessionID == Common.SessionID) select o.BIMID;

            context.Response.Write(JsonConvert.SerializeObject(q));
        }
コード例 #2
0
 private void SaveProfile(HttpContext context)
 {
     PindexProd.dbml.AppUsers u = this.GetPindexProdContext2.AppUsers.First(o => o.ID == Common.UserID);
     if (string.IsNullOrEmpty(u.Password))
     {
         context.Response.WriteError("Password not updated");
     }
     else
     {
         string email      = context.Request.Params["email"];
         string first_name = context.Request.Params["first_name"];
         string about      = context.Request.Params["about"];
         string location   = context.Request.Params["location"];
         string fn         = context.Request.Params["fn"];
         string website    = context.Request.Params["website"];
         string name       = context.Request.Params["name"];
         if (!string.IsNullOrEmpty(fn))
         {
             Uri      uri          = new Uri(fn);
             string   filename     = uri.Segments.Last();
             string   fp           = Path.Combine(Common.Temp, Common.UserID.ToString(), filename);
             string   uploadedpath = Common.UploadedImagePath;
             FileInfo fInfo        = new FileInfo(fp);
             string   nfn          = fInfo.Name;
             if (fInfo.DirectoryName != uploadedpath)
             {
                 string dest = Path.Combine(uploadedpath, nfn);
                 fInfo.MoveTo(dest);
             }
             u.Avatar = nfn;
         }
         u.Location  = location;
         u.Email     = email;
         u.FirstName = first_name;
         u.Website   = website;
         u.Location  = location;
         u.About     = about;
         u.Name      = name;
         GetPindexProdContext2.SubmitChanges();
         CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = u.ID }), Common.DefaultPassword), false);
         CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = u.Email, name = u.Name, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar }), false);
     }
 }
コード例 #3
0
        private void ResetPass(HttpContext context)
        {
            string email = context.Request.Params["email"];

            PindexProd.dbml.AppUsers user = this.GetPindexProdContext2.AppUsers.FirstOrDefault(o => o.Email == email);
            if (user != null)
            {
                SmtpClient  client = new SmtpClient();
                MailMessage mess   = new MailMessage("*****@*****.**", email);
                string      pass   = Common.RandomString(Common.PassMinChars);
                mess.Body       = string.Format(File.ReadAllText(context.Server.MapPath("resetpasstmpl.html")), user.Name, user.Email, pass);
                mess.Subject    = "Password reset for your Freshpin account";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Password = Common.GetHash(pass);
                GetPindexProdContext2.SubmitChanges();
                context.Response.Write("The new password has been sent to your email address");
            }
            else
            {
                context.Response.Write("The email address is not registered with our application");
            }
        }