Пример #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"]);

            Lipstick.dbml.Review review = GetLipstickContext2.Review.FirstOrDefault(o => o.BIMID == bimid && (o.UserID == Common.UserID || o.SessionID == Common.SessionID));
            if (review == null)
            {
                review           = new Lipstick.dbml.Review();
                review.Answer    = answer;
                review.BIMID     = bimid;
                review.Question  = question;
                review.UserID    = Common.UserID;
                review.SessionID = Common.SessionID;
                GetLipstickContext2.Review.InsertOnSubmit(review);
                if (Common.UserID.HasValue)
                {
                    GetLipstickContext1.Update(new POCOS.AppUser()
                    {
                        ID = Common.UserID.Value, Points = Common.Points
                    }, new[] { "Points" });
                }
            }
            else
            {
                review.Answer   = answer;
                review.Question = question;
            }
            GetLipstickContext2.SubmitChanges();
            var q = from o in GetLipstickContext2.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)
 {
     Lipstick.dbml.AppUsers u = this.GetLipstickContext2.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;
         GetLipstickContext2.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"];

            Lipstick.dbml.AppUsers user = this.GetLipstickContext2.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 PinPolish account";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Password = Common.GetHash(pass);
                GetLipstickContext2.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");
            }
        }