Esempio n. 1
0
        private void DeletePin(HttpContext context)
        {
            int BIMID = int.Parse(context.Request.Params["BIMID"]);

            GetDataContext2.DeletePin(BIMID, Common.UserID.Value);
            UpdateUPCount();
        }
Esempio n. 2
0
        private void SaveLike(HttpContext context)
        {
            int  id    = int.Parse(context.Request.Params["id"]);
            bool liked = bool.Parse(context.Request.Params["liked"]);

            if (liked)
            {
                Data.dbml.Likes l = new Data.dbml.Likes();
                l.BoardsImagesMappingID = id;
                l.UserID = Common.UserID.Value;
                GetDataContext2.Likes.InsertOnSubmit(l);
                GetDataContext2.SubmitChanges();
            }
            else
            {
                PredicateGroup group = new PredicateGroup()
                {
                    Operator = GroupOperator.And, Predicates = new List <IPredicate>()
                };
                group.Predicates.Add(Predicates.Field <Data.Standalone.Likes>(f => f.BoardsImagesMappingID, Operator.Eq, id));
                group.Predicates.Add(Predicates.Field <Data.Standalone.Likes>(f => f.UserID, Operator.Eq, Common.UserID));
                SqlConnection.Delete <Data.Standalone.Likes>(group);
            }
            UpdateUPCount();
        }
Esempio n. 3
0
        private void DelBoard(HttpContext context)
        {
            int boardid = int.Parse(context.Request.Params["boardid"]);

            GetDataContext2.DeleteBoard(boardid);
            UpdateUPCount();
        }
Esempio n. 4
0
 private void CreateBoard(HttpContext context)
 {
     Data.dbml.Boards boards = new Data.dbml.Boards();
     boards.Name = context.Request.Params["name"];
     GetDataContext2.Boards.InsertOnSubmit(boards);
     GetDataContext2.SubmitChanges();
 }
Esempio n. 5
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"]);

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

            context.WriteJsonP(JsonConvert.SerializeObject(q));
        }
Esempio n. 6
0
        private void UnFollowUser(HttpContext context)
        {
            int?UnFollowID = context.Request.Params["F_ID"].ToInt() ?? Common.VUserID;
            var fdel       = GetDataContext2.FollowingUser.Single(a => a.UserID == Common.UserID && a.FollowingID == UnFollowID);

            GetDataContext2.FollowingUser.DeleteOnSubmit(fdel);
            GetDataContext2.SubmitChanges();
            UpdateFlCount();
        }
Esempio n. 7
0
        private void SaveEditPin(HttpContext context)
        {
            int BIMID = int.Parse(context.Request.Params["BIMID"]);
            var pin   = GetDataContext2.BoardsImagesMapping.Where(bim => bim.ID == BIMID && bim.UserID == Common.UserID).FirstOrDefault();

            if (pin != null)
            {
                pin.Image_Title = context.Request.Params["desc"];
                pin.Source      = context.Request.Params["source"];
                pin.BoardID     = int.Parse(context.Request.Params["board"]);
            }
            GetDataContext2.SubmitChanges();
        }
Esempio n. 8
0
        private void FollowUser(HttpContext context)
        {
            int?FollowID = context.Request.Params["F_ID"].ToInt() ?? Common.VUserID;

            GetDataContext2.FollowingUser.InsertOnSubmit(new Data.dbml.FollowingUser()
            {
                FollowingID = FollowID.Value,
                UserID      = Common.UserID.Value,
                Create_Date = DateTime.Now
            });
            GetDataContext2.SubmitChanges();
            UpdateFlCount();
        }
Esempio n. 9
0
        private void ChangePassword(HttpContext context)
        {
            string pass = context.Request.Params["pass"];

            if (!string.IsNullOrEmpty(pass))
            {
                Data.dbml.AppUsers u = this.GetDataContext2.AppUsers.First(o => o.ID == Common.UserID);
                IHash      hash      = Common.Hash;
                HashResult res       = hash.ComputeString(pass);
                u.Password = Common.GetString(res.GetBytes());
                GetDataContext2.SubmitChanges();
                context.Response.Write(strings.Pass_Updated);
            }
        }
Esempio n. 10
0
        private void UpdatePrize(HttpContext context)
        {
            Random rnd   = new Random();
            double angle = rnd.Next(45, 360);
            var    prize = (from r in GetDataContext2.Roulette
                            join p in GetDataContext2.Prize
                            on r.PrizeID equals p.ID
                            where (r.End_Angle >= angle && r.Start_Angle <= angle)
                            select new
            {
                r.PrizeID,
                p.Prize_Name,
                p.User_Alert
            }).First();
            var user        = GetDataContext2.AppUsers.First(o => o.ID == Common.UserID);
            int user_points = Convert.ToInt32(user.Points);
            int rwpointded  = Common.RWPointsDed;

            if (user_points >= rwpointded)
            {
                user_points = user_points - rwpointded;
                Common.WriteValue(Common.InfoCookie, JObject.FromObject(new { points = user_points }));
                user.Points = user_points + PrizeValue(prize.Prize_Name);
                GetDataContext2.SubmitChanges();
                GetDataContext2.PrizeHistory.InsertOnSubmit(new Data.dbml.PrizeHistory()
                {
                    PrizeID     = prize.PrizeID,
                    UserID      = Common.UserID.Value,
                    Create_date = DateTime.Now
                });
                GetDataContext2.SubmitChanges();
                context.WriteJsonP(JsonConvert.SerializeObject(new
                {
                    angle  = angle,
                    alert  = prize.User_Alert,
                    points = user.Points
                }, Formatting.Indented, Common.JsonSerializerSettings));
            }
            else
            {
                context.Response.WriteError(string.Format(misc.NoPointsAlert, rwpointded));
            }
        }
Esempio n. 11
0
        private void AddProfile(HttpContext context)
        {
            Data.dbml.AppUsers u          = new Data.dbml.AppUsers();
            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"];
            string             pass       = context.Request.Params["pass"];
            string             email      = context.Request.Params["email"];
            string             speciality = context.Request.Params["speciality"];

            if (!string.IsNullOrEmpty(fn))
            {
                Uri      uri          = new Uri(fn);
                string   filename     = uri.Segments.Last();
                string   fp           = Path.Combine(Common.Temp, 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.Email       = email;
            u.Location    = location;
            u.Create_date = DateTime.Now;
            u.FirstName   = first_name;
            u.Website     = website;
            u.Location    = location;
            u.About       = about;
            u.Name        = name;
            u.Speciality  = speciality;
            u.Password    = Common.GetHash(pass);
            GetDataContext2.AppUsers.InsertOnSubmit(u);
            GetDataContext2.SubmitChanges();
            Common.WriteValue(Common.AuthCookie, u.ID.ToString());
            Common.WriteValue(Common.InfoCookie, JObject.FromObject(new { email = u.Email, name = string.IsNullOrEmpty(u.FirstName) ? u.Name : u.FirstName, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar }));
        }
Esempio n. 12
0
 private void SaveProfile(HttpContext context)
 {
     Data.dbml.AppUsers u = this.GetDataContext2.AppUsers.First(o => o.ID == Common.UserID);
     if (string.IsNullOrEmpty(u.Password))
     {
         context.Response.WriteError(strings.Pass_Created);
     }
     else
     {
         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"];
         string speciality = context.Request.Params["speciality"];
         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.FirstName  = first_name;
         u.Website    = website;
         u.Location   = location;
         u.About      = about;
         u.Name       = name;
         u.Speciality = speciality;
         GetDataContext2.SubmitChanges();
         Common.WriteValue(Common.InfoCookie, JObject.FromObject(new { email = u.Email, speciality, name = string.IsNullOrEmpty(u.FirstName) ? u.Name : u.FirstName, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar }));
     }
 }
Esempio n. 13
0
        private void ResetPass(HttpContext context)
        {
            string email = context.Request.Params["email"];

            Data.dbml.AppUsers user = this.GetDataContext2.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 Pinjimu account";
                mess.IsBodyHtml = true;
                client.Send(mess);
                user.Password = Common.GetHash(pass);
                GetDataContext2.SubmitChanges();
                context.Response.Write(strings.Pass_Reset);
            }
            else
            {
                context.Response.Write(strings.Email_Not_Reg);
            }
        }
Esempio n. 14
0
 private void Board(HttpContext context)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         try
         {
             int  catid    = int.Parse(context.Request.Params["catid"]);
             int  imageId  = int.Parse(context.Request.Params["imageId"]);
             bool _checked = bool.Parse(context.Request.Params["checked"]);
             if (_checked)
             {
                 GetDataContext2.BoardsImagesMapping.InsertOnSubmit(new Data.dbml.BoardsImagesMapping()
                 {
                     ImageID = imageId,
                     BoardID = catid,
                     UserID  = Common.UserID
                 });
             }
             else
             {
                 var query = GetDataContext2.BoardsImagesMapping.Where(o => o.BoardID == catid && o.ImageID == imageId);
                 GetDataContext2.BoardsImagesMapping.DeleteAllOnSubmit(query);
             }
             GetDataContext2.SubmitChanges();
             SqlHelper.ExecuteNonQuery((SqlConnection)((EntityConnection)this.GetDataContext2.Connection).StoreConnection, "dbo.SetTaggedFlag", imageId);
             scope.Complete();
         }
         catch (Exception e)
         {
             throw;
         }
         finally
         {
             scope.Dispose();
         }
     }
 }
Esempio n. 15
0
 private void Cat(HttpContext context)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         try
         {
             int  catid    = int.Parse(context.Request.Params["catid"]);
             int  imageId  = int.Parse(context.Request.Params["imageId"]);
             bool _checked = bool.Parse(context.Request.Params["checked"]);
             if (_checked)
             {
                 GetDataContext2.CategoryImagesMapping.InsertOnSubmit(new Data.dbml.CategoryImagesMapping()
                 {
                     ImageID    = imageId,
                     CategoryID = catid,
                     UserID     = Common.UserID
                 });
             }
             else
             {
                 var query = GetDataContext2.CategoryImagesMapping.Where(o => o.CategoryID == catid && o.ImageID == imageId);
                 GetDataContext2.CategoryImagesMapping.DeleteAllOnSubmit(query);
             }
             GetDataContext2.SubmitChanges();
             GetDataContext3.SetTaggedFlag(imageId);
             scope.Complete();
         }
         catch (Exception e)
         {
             throw;
         }
         finally
         {
             scope.Dispose();
         }
     }
 }