示例#1
0
 public List <User> Get(string userName)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         return(context.Users.Where(
                    x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)).ToList());
     }
 }
示例#2
0
 public void Add(SiteMap siteMap)
 {
     using (var context = new PunchClockDbContext())
     {
         context.SiteMaps.Add(siteMap);
         context.SaveChanges();
     }
 }
示例#3
0
 public User Details(string userName)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         return(context.Users.FirstOrDefault(
                    x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)));
     }
 }
示例#4
0
 public List <User> GetAllUsers(int companyId)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         return(context.Users.Where(
                    x => x.CompanyId.Equals(companyId)).ToList());
     }
 }
示例#5
0
 public User Details(int userId)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         return(context.Users.FirstOrDefault(
                    x => x.Uid.Equals(userId)));
     }
 }
示例#6
0
 public User ByEmail(string email)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         return(context.Users.FirstOrDefault(
                    x => x.Email.Equals(email, StringComparison.OrdinalIgnoreCase)));
     }
 }
示例#7
0
 public User ByGuid(string guid)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         return(context.Users.FirstOrDefault(
                    x => x.Id.Equals(guid, StringComparison.OrdinalIgnoreCase)));
     }
 }
示例#8
0
 public void Add(Punch punch)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         context.Punches.Add(punch);
         context.SaveChanges();
     }
 }
示例#9
0
 public List <TicketProject> GetProjects(int companyId)
 {
     using (var context = new PunchClockDbContext())
     {
         return(context.TicketProjects.Where(x => x.CompanyId == companyId || x.IsCoreItem).OrderBy(x => x.DisplayOrder)
                .ToList());
     }
 }
示例#10
0
 public TicketStatus Add(TicketStatus status)
 {
     using (var context = new PunchClockDbContext())
     {
         context.TicketStatuses.Add(status);
         context.SaveChanges();
     }
     return(status);
 }
示例#11
0
 public TicketPriority Add(TicketPriority priority)
 {
     using (var context = new PunchClockDbContext())
     {
         context.TicketPriorities.Add(priority);
         context.SaveChanges();
     }
     return(priority);
 }
示例#12
0
 public TicketProject Add(TicketProject project)
 {
     using (var context = new PunchClockDbContext())
     {
         context.TicketProjects.Add(project);
         context.SaveChanges();
     }
     return(project);
 }
示例#13
0
 public int Add(AppSetting appSetting)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         context.AppSettings.Add(appSetting);
         context.SaveChanges();
         return(appSetting.Id);
     }
 }
示例#14
0
 public EmployeeInvite ByInviteKey(string id)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         var invite = context.EmployeeInvites.Include(x => x.Company)
                      .FirstOrDefault(x => x.GlobalId == id && !x.InviteRevoked);
         return(invite);
     }
 }
示例#15
0
        private void SeedArticleTags(PunchClockDbContext context)
        {
            var articleTags = new List <ArticleTag>
            {
                new ArticleTag
                {
                    Id              = 1,
                    Name            = "Home",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = 1
                },
                new ArticleTag
                {
                    Id              = 2,
                    Name            = "Social",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                }
                ,
                new ArticleTag
                {
                    Id              = 3,
                    Name            = "Fashion",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                }
                ,
                new ArticleTag
                {
                    Id              = 4,
                    Name            = "Technology",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                }
            };

            foreach (var tag in articleTags)
            {
                context.ArticleTags.AddOrUpdate(tag);
            }
        }
示例#16
0
 public TicketType Add(TicketType type)
 {
     using (var context = new PunchClockDbContext())
     {
         context.TicketTypes.Add(type);
         context.SaveChanges();
     }
     return(type);
 }
示例#17
0
        private void SeedArticleCategory(PunchClockDbContext context)
        {
            var articleCategories = new List <ArticleCategory>
            {
                new ArticleCategory
                {
                    Id              = 1,
                    Name            = "SuperAdmin",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                },
                new ArticleCategory
                {
                    Id              = 2,
                    Name            = "RBTek",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                }
                ,
                new ArticleCategory
                {
                    Id              = 3,
                    Name            = "CMS",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                }
                ,
                new ArticleCategory
                {
                    Id              = 4,
                    Name            = "Ticketing",
                    Description     = "",
                    CreatedDateUtc  = DateTime.UtcNow,
                    CreatedBy       = null,
                    ModifiedById    = null,
                    ModifiedDateUtc = DateTime.UtcNow,
                    CompanyId       = context.Companies.First().Id
                }
            };

            foreach (var category in articleCategories)
            {
                context.ArticleCategrories.AddOrUpdate(category);
            }
        }
示例#18
0
 public List <SiteMap> All(int companyId, bool isAdmin)
 {
     using (var context = new PunchClockDbContext())
     {
         return(isAdmin
             ? context.SiteMaps.ToList()
             : context.SiteMaps.Where(x => x.CompanyId == companyId).ToList());
     }
 }
示例#19
0
 public ArticleCategory Add(ArticleCategory category)
 {
     using (var context = new PunchClockDbContext())
     {
         context.ArticleCategrories.Add(category);
         context.ArticleCategoryResources.AddRange(category.Resources);
         context.SaveChanges();
     }
     return(category);
 }
示例#20
0
 public List <TicketCategory> GetCategoryByCompanyIdList(int companyId)
 {
     using (var context = new PunchClockDbContext())
     {
         return
             (context.TicketCategories.Where(x => x.IsDeleted == false && x.CompanyId == companyId)
              .Include(x => x.TicketProject)
              .ToList());
     }
 }
示例#21
0
 public TicketCategory Add(TicketCategory category)
 {
     using (var context = new PunchClockDbContext())
     {
         context.TicketCategories.Add(category);
         context.SaveChanges();
         category = context.TicketCategories.Include(x => x.TicketProject).FirstOrDefault(x => x.Id == category.Id);;
     }
     return(category);
 }
示例#22
0
 public TicketAttachment Add(TicketAttachment attachment)
 {
     using (var context = new PunchClockDbContext())
     {
         attachment.CreatedDateUtc = DateTime.UtcNow;
         context.TicketAttachments.Add(attachment);
         context.SaveChanges();
     }
     return(attachment);
 }
示例#23
0
 public ArticleComment Add(ArticleComment comment)
 {
     using (var context = new PunchClockDbContext())
     {
         comment.IsDeleted = false;
         context.ArticleComments.Add(comment);
         context.SaveChanges();
     }
     return(comment);
 }
示例#24
0
        public List <Punch> All(int userId, bool isAdmin)
        {
            PunchClockDbContext context = new PunchClockDbContext();

            if (isAdmin)
            {
                return(context.Punches.Include(x => x.User).ToList());
            }
            return(context.Punches.Where(x => x.UserId == userId).Include(x => x.User).ToList());
        }
示例#25
0
 public ArticleTag Add(ArticleTag articleTag)
 {
     using (var context = new PunchClockDbContext())
     {
         articleTag.IsDeleted = false;
         context.ArticleTags.Add(articleTag);
         context.ArticleTagResources.AddRange(articleTag.Resources);
         context.SaveChanges();
     }
     return(articleTag);
 }
示例#26
0
 public int AddAddress(Address address)
 {
     using (var context = new PunchClockDbContext())
     {
         address.Country = context.Countries.FirstOrDefault(x => x.Id == address.CountryId);
         address.State   = context.States.FirstOrDefault(x => x.Id == address.StateId);
         context.Addresses.Add(address);
         context.SaveChanges();
         return(address.Id);
     }
 }
示例#27
0
 public string Invite(EmployeeInvite invite)
 {
     using (PunchClockDbContext context = new PunchClockDbContext())
     {
         invite.GlobalId = Guid.NewGuid().ToString("D");
         invite.UserType = context.UserTypes.FirstOrDefault(x => x.Id == invite.UserTypeId);
         context.EmployeeInvites.AddOrUpdate(invite);
         context.SaveChanges();
         return(invite.GlobalId);
     }
 }
示例#28
0
        public ArticleType Add(ArticleType articleType)
        {
            using (var context = new PunchClockDbContext())
            {
                articleType.IsDeleted = false;
                context.ArticleTypes.Add(articleType);
                context.ArticleTypeResources.AddRange(articleType.Resources);
                context.SaveChanges();
            }

            return(articleType);
        }
示例#29
0
 public void SetCreatedBy(int companyId, string userId)
 {
     using (var context = new PunchClockDbContext())
     {
         var company = context.Companies.FirstOrDefault(x => x.Id.Equals(companyId));
         if (company != null)
         {
             company.CreatedById = userId;
         }
         context.SaveChanges();
     }
 }
示例#30
0
        private void SeedCompany(PunchClockDbContext context)
        {
            List <Company> companies = new List <Company>
            {
                _firstCompany
            };

            foreach (var company in companies)
            {
                context.Companies.AddOrUpdate(company);
            }
        }