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()); } }
// [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 }); }
public UserProfile(MKContext db) { db.UserDataSet.Add(new UserData(db) { UserProfile = this }); }
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); }
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(); }
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); }
public UserData(MKContext db) { db.ShoppingCarts.Add(new ShoppingCart { UserData = this }); }
// 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)); }