public async Task <int> DeleteUser(User user) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); context.Users.Remove(user); return(await context.SaveChangesAsync()); }
public async Task <int> PutTicketUser(TicketUser ticketUser) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); context.Entry(ticketUser).State = EntityState.Modified; return(await context.SaveChangesAsync()); }
public async Task <List <TicketUserJoinTicketStoreJoinStore> > getTicketsUsersBelongToStore(long storeId) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); var data = (from tu in context.TicketsUsers join ts in context.TicketsStores on tu.TicketStoreId equals ts.Id join s in context.Stores on ts.StoreId equals s.Id where s.Id == storeId select new TicketUserJoinTicketStoreJoinStore { Id = tu.Id, UserId = tu.UserId, TicketStoreId = tu.TicketStoreId, Punch = tu.Punch, Status = tu.Status, CreatedDate = tu.CreatedDate, LastPunching = tu.LastPunching, TempCode = tu.TempCode, CreatedTempCode = tu.CreatedTempCode, TotalPunches = ts.TotalPunches, StoreName = s.Name, TicketTypeId = ts.TicketTypeId, PunchValue = ts.PunchValue, GiftDescription = ts.GiftDescription }).ToListAsync(); return(await data); }
public async Task <ActionResult <TicketUser> > GetTicketUser(int tempCode, long ticketStoreId) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.TicketsUsers.FirstOrDefaultAsync(tu => tu.TempCode == tempCode && tu.TicketStoreId == ticketStoreId)); }
/*public async Task<ActionResult<TicketUser>> GetTicketUser(long id) * { * using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); * var ticketUser = await context.TicketsUsers.FindAsync(id); * * return ticketUser; * }*/ public async Task <int> CreateTicketUser(TicketUser ticketUser) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); context.TicketsUsers.Add(ticketUser); return(await context.SaveChangesAsync()); }
public async Task <int> DeleteStore(Store store) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); context.Stores.Remove(store); return(await context.SaveChangesAsync()); }
public async Task <List <TicketUser> > GetTicketsUsers() { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.TicketsUsers .ToListAsync()); }
public async Task <int> CreatePunchHistory(PunchHistory punchHistory) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); context.PunchingHistory.Add(punchHistory); return(await context.SaveChangesAsync()); }
public async Task <ActionResult <Store> > GetStore(long id) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.Stores.FindAsync(id)); }
public async Task <ActionResult <TicketUser> > GetTicketUser(long userId, long ticketStoreId, bool status) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.TicketsUsers.FirstOrDefaultAsync(tu => tu.UserId == userId && tu.TicketStoreId == ticketStoreId && tu.Status == status)); }
public async Task <List <Store> > GetStores(long userId) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.Stores .Where(s => s.UserId == userId) .ToListAsync()); }
public async Task <List <TicketStore> > GetTicketsStore(long storeId) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.TicketsStores .Where(ts => ts.StoreId == storeId) .ToListAsync()); }
public async Task <List <User> > GetPage(int pageNumber, int pageSize) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.Users .Skip((pageNumber - 1) *pageSize) .Take(pageSize) .ToListAsync()); }
public async Task <List <TicketStore> > GetTicketsStoresWithJoin(long userId) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); var data = (from s in context.Stores join ts in context.TicketsStores on s.Id equals ts.StoreId where s.UserId == userId select new TicketStore { Id = ts.Id, StoreId = ts.StoreId, TicketTypeId = ts.TicketTypeId, TicketPrice = ts.TicketPrice, TotalPunches = ts.TotalPunches }).ToListAsync(); return(await data); }
public bool IsPhoneExists(string phone) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(context.Users.Any(e => e.Phone == phone)); }
public bool Exists(long id) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(context.TicketsUsers.Any(e => e.Id == id)); }
/*public async Task<User> GetUser(string email, string password) * { * using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); * * return await context.Users.FirstOrDefaultAsync(u => u.Email == email && u.Password == password); * }*/ public async Task <User> GetUser(string email) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.Users.FirstOrDefaultAsync(u => u.Email == email)); }
public bool IsEmailExists(string email) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(context.Users.Any(e => e.Email == email)); }
public async Task <int> GetRecords() { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.Users.CountAsync()); }
public async Task <ActionResult <TicketType> > GetTicketType(int id) { using var context = new DevTicketDatabaseContext(DevTicketDatabaseContext.ops.dbOptions); return(await context.TicketTypes.FindAsync(id)); }