public List <User> Get(string userName) { using (PunchClockDbContext context = new PunchClockDbContext()) { return(context.Users.Where( x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)).ToList()); } }
public void Add(SiteMap siteMap) { using (var context = new PunchClockDbContext()) { context.SiteMaps.Add(siteMap); context.SaveChanges(); } }
public User Details(string userName) { using (PunchClockDbContext context = new PunchClockDbContext()) { return(context.Users.FirstOrDefault( x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase))); } }
public List <User> GetAllUsers(int companyId) { using (PunchClockDbContext context = new PunchClockDbContext()) { return(context.Users.Where( x => x.CompanyId.Equals(companyId)).ToList()); } }
public User Details(int userId) { using (PunchClockDbContext context = new PunchClockDbContext()) { return(context.Users.FirstOrDefault( x => x.Uid.Equals(userId))); } }
public User ByEmail(string email) { using (PunchClockDbContext context = new PunchClockDbContext()) { return(context.Users.FirstOrDefault( x => x.Email.Equals(email, StringComparison.OrdinalIgnoreCase))); } }
public User ByGuid(string guid) { using (PunchClockDbContext context = new PunchClockDbContext()) { return(context.Users.FirstOrDefault( x => x.Id.Equals(guid, StringComparison.OrdinalIgnoreCase))); } }
public void Add(Punch punch) { using (PunchClockDbContext context = new PunchClockDbContext()) { context.Punches.Add(punch); context.SaveChanges(); } }
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()); } }
public TicketStatus Add(TicketStatus status) { using (var context = new PunchClockDbContext()) { context.TicketStatuses.Add(status); context.SaveChanges(); } return(status); }
public TicketPriority Add(TicketPriority priority) { using (var context = new PunchClockDbContext()) { context.TicketPriorities.Add(priority); context.SaveChanges(); } return(priority); }
public TicketProject Add(TicketProject project) { using (var context = new PunchClockDbContext()) { context.TicketProjects.Add(project); context.SaveChanges(); } return(project); }
public int Add(AppSetting appSetting) { using (PunchClockDbContext context = new PunchClockDbContext()) { context.AppSettings.Add(appSetting); context.SaveChanges(); return(appSetting.Id); } }
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); } }
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); } }
public TicketType Add(TicketType type) { using (var context = new PunchClockDbContext()) { context.TicketTypes.Add(type); context.SaveChanges(); } return(type); }
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); } }
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()); } }
public ArticleCategory Add(ArticleCategory category) { using (var context = new PunchClockDbContext()) { context.ArticleCategrories.Add(category); context.ArticleCategoryResources.AddRange(category.Resources); context.SaveChanges(); } return(category); }
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()); } }
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); }
public TicketAttachment Add(TicketAttachment attachment) { using (var context = new PunchClockDbContext()) { attachment.CreatedDateUtc = DateTime.UtcNow; context.TicketAttachments.Add(attachment); context.SaveChanges(); } return(attachment); }
public ArticleComment Add(ArticleComment comment) { using (var context = new PunchClockDbContext()) { comment.IsDeleted = false; context.ArticleComments.Add(comment); context.SaveChanges(); } return(comment); }
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()); }
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); }
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); } }
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); } }
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); }
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(); } }
private void SeedCompany(PunchClockDbContext context) { List <Company> companies = new List <Company> { _firstCompany }; foreach (var company in companies) { context.Companies.AddOrUpdate(company); } }