示例#1
0
        public Models.User Get(Models.User dummy)
        {
            var entity = SiteDbContext.CreateDbContext().SiteUsers
                         .Where(it => it.SiteName == dummy.Site.FullName && it.UserName == dummy.UserName)
                         .FirstOrDefault();

            return(entity == null ? null : SiteUserHelper.ToUser(entity));
        }
示例#2
0
 public IEnumerable <Models.User> All(Models.Site site)
 {
     return(SiteDbContext.CreateDbContext().SiteUsers
            .Where(it => it.SiteName == site.FullName)
            .ToArray()
            .Select(it => SiteUserHelper.ToUser(it))
            .AsQueryable());
 }
示例#3
0
        private void InsertOrUpdate(Models.User @new, Models.User old)
        {
            var dbContext = SiteDbContext.CreateDbContext();
            var entity    = dbContext.SiteUsers
                            .Where(it => it.SiteName == @new.Site.FullName && it.UserName == @new.UserName)
                            .FirstOrDefault();

            if (entity != null)
            {
                entity = SiteUserHelper.ToEntity(@new, entity);
            }
            else
            {
                entity = entity = SiteUserHelper.ToEntity(@new, entity);
                dbContext.SiteUsers.Add(entity);
            }

            dbContext.SaveChanges();
        }