Exemple #1
0
 public static UserProfile GetUserProfile(this System.Security.Principal.IIdentity iidentity)
 {
     using (var db = new MKContext())
     {
         return(db.UserProfiles.Where(u => u.UserName == iidentity.Name).FirstOrDefault());
     }
 }
Exemple #2
0
//         [DataType(DataType.Password)]
//         [Display(Name = "Password confirm")]
//         [Compare("Password", ErrorMessage = "Passwords're not matched")]
//         public string ConfirmPassword { get; set; }

        public void AddUserProfile(MKContext db)
        {
            db.UserProfiles.Add(new UserProfile(db)
            {
                Email = Email, UserName = UserName
            });
        }
Exemple #3
0
 public UserProfile(MKContext db)
 {
     db.UserDataSet.Add(new UserData(db)
     {
         UserProfile = this
     });
 }
Exemple #4
0
        public static UserProfile GetUserProfile(this MKContext db, string name)
        {
            var user = db.UserProfiles.Where(u => u.UserName == name).FirstOrDefault();

            if (user == null)
            {
                if (WebMatrix.WebData.WebSecurity.Initialized)
                {
                    WebMatrix.WebData.WebSecurity.Logout();
                }
            }
            return(user);
        }
Exemple #5
0
        public static void IncPageView(this MKContext db, Item item)
        {
            var pv = item.PageView;

            if (pv == null)
            {
                pv = new PageView {
                    Item = item
                };
                db.PageViews.Add(pv);
            }
            pv.VisitCount++;
            db.SaveChanges();
        }
Exemple #6
0
        public static int GetPageViewCount(this MKContext db, Item item)
        {
            var pv = item.PageView;

            if (pv == null)
            {
                pv = new PageView {
                    Item = item
                };
                db.PageViews.Add(pv);
                db.SaveChanges();
            }
            return(pv.VisitCount);
        }
Exemple #7
0
 public UserData(MKContext db)
 {
     db.ShoppingCarts.Add(new ShoppingCart {
         UserData = this
     });
 }
Exemple #8
0
//         public static void AddItem(this MKContext db, Item item)
//         {
//             db.Items.Add(item);
//             if (item.IsAlbum)
//             {
//                 db.ItemMetaSet.Where("");
//             }
//         }

        public static int GetAllPageViewCount(this MKContext db)
        {
            return(db.PageViews.Count() == 0 ? 0 : db.PageViews.Sum(p => p.VisitCount));
        }