/// <summary> /// Create TimeBlocks /// </summary> /// <param name="timeBlock"></param> /// <returns> return true if success else false </returns> public bool CreateNewTimeBlockRange(params TimeBlock[] timeBlocks) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { db.TimeBlocks.AddRange(timeBlocks); return(db.SaveChanges() > 0); } }
/// <summary> /// Create NewAppUser return true if success else false /// </summary> /// <param name="newAppUser"></param> public bool CreateNewAppUser(AppUser newUser) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { db.Users.Add(newUser); return(db.SaveChanges() > 0); } }
/// <summary> /// Get all the Schedule by No in the database /// </summary> /// <param name="no"></param> /// <returns></returns> public Schedule GetScheduleByNo(int no) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var Schedule = db.Schedules.Where(schedule => schedule.No == no).FirstOrDefault <Schedule>(); return(Schedule); } }
/// <summary> /// Get the user by UserNo /// </summary> /// <param name="no"></param> /// <returns>If User No does not exist return null else return matching user </returns> public AppUser GetAppUserByNo(int userNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var user = db.Users.Where(appUser => appUser.No == userNo).FirstOrDefault <AppUser>(); return(user); } }
/// <summary> /// Create TimeBlock /// </summary> /// <param name="timeBlock"></param> /// <returns> return true if success else false </returns> public bool CreateNewTimeBlock(TimeBlock timeBlock) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { db.TimeBlocks.Add(timeBlock); return(db.SaveChanges() > 0); } }
/// <summary> /// Get all the Users in the database /// </summary> /// <returns>List of AppUser in Database</returns> public List <AppUser> GetAppUsers() { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var userList = db.Users.ToList <AppUser>(); return(userList); } }
/// <summary> /// Get all the TimeBlocks that has specific user No in the database /// </summary> /// <returns></returns> public List <TimeBlock> GetTimeBlocksByUserNo(int userNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeblockList = db.TimeBlocks.Where(timeblock => timeblock.Schedule.UserNo == userNo).ToList <TimeBlock>(); return(timeblockList); } }
/// <summary> /// Get the Timeblocks with No /// </summary> /// <param name="no"></param> /// <returns>If TimeBlock No does not exist return null else return matching TimeBlock </returns> public TimeBlock GetTimeBlockByNo(int no) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var Timeblock = db.TimeBlocks.Where(timeBlock => timeBlock.No == no).FirstOrDefault <TimeBlock>(); return(Timeblock); } }
/// <summary> /// Get all the Schedules in the database /// </summary> /// <returns></returns> public List <Schedule> GetSchedules() { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var scheduleList = db.Schedules.ToList <Schedule>(); return(scheduleList); } }
/// <summary> /// Get all the TimeBlocks in the database /// </summary> /// <returns></returns> public List <TimeBlock> GetTimeBlocks() { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeBlockList = db.TimeBlocks.ToList <TimeBlock>(); return(timeBlockList); } }
/// <summary> /// Create newSchedule return true if success else false /// </summary> /// <param name="schedule"></param> public bool CreateNewSchedule(Schedule schedule) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { db.Schedules.Add(schedule); return(db.SaveChanges() > 0); } }
/// <summary> /// Get all the Schedules by UserNo in the database /// </summary> /// <param name="userNo"></param> /// <returns></returns> public List <Schedule> GetSchedulesByUserNo(int userNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var scheduleList = db.Schedules.Where(schedule => schedule.UserNo == userNo).ToList <Schedule>(); return(scheduleList); } }
/// <summary> /// Get the user by UserNo Async /// </summary> /// <param name="no"></param> /// <returns>If User No does not exist return null else return matching user </returns> public async Task <AppUser> GetAppUserByNoAsync(int userNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var user = await db.Users.Where(appUser => appUser.No == userNo).FirstOrDefaultAsync <AppUser>(); return(user); } }
/// <summary> /// Create NewAppUser return true if success else false /// Async /// </summary> /// <param name="newAppUser"></param> public async Task <bool> CreateNewAppUserAsync(AppUser newUser) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { await db.Users.AddAsync(newUser); return(db.SaveChanges() > 0); } }
/// <summary> /// Get all the TimeBlocks that has specific scheduler No in the database async /// </summary> /// <returns></returns> public async Task <List <TimeBlock> > GetTimeBlocksByScheduleNoAsync(int scheduleNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeblockList = await db.TimeBlocks.Where(timeblock => timeblock.ScheduleNo == scheduleNo).ToListAsync <TimeBlock>(); return(timeblockList); } }
/// <summary> /// Create newSchedule return true if success else false Async /// </summary> /// <param name="schedule"></param> public async Task <bool> CreateNewScheduleAsync(Schedule schedule) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { await db.Schedules.AddAsync(schedule); return(db.SaveChanges() > 0); } }
/// <summary> /// Get all the Schedules by UserNo in the database Async /// </summary> /// <param name="userNo"></param> /// <returns></returns> public async Task <List <Schedule> > GetSchedulesByUserNoAsync(int userNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var scheduleList = await db.Schedules.Where(schedule => schedule.UserNo == userNo).ToListAsync <Schedule>(); return(scheduleList); } }
/// <summary> /// Get all the Schedule by No in the database Async /// </summary> /// <param name="no"></param> /// <returns></returns> public async Task <Schedule> GetScheduleByNoAsync(int no) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var Schedule = await db.Schedules.Where(schedule => schedule.No == no).FirstOrDefaultAsync <Schedule>(); return(Schedule); } }
/// <summary> /// Get the Timeblocks with No Async /// </summary> /// <param name="no"></param> /// <returns>If TimeBlock No does not exist return null else return matching TimeBlock </returns> public async Task <TimeBlock> GetTimeBlockByNoAsync(int no) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var Timeblock = await db.TimeBlocks.Where(timeBlock => timeBlock.No == no).FirstOrDefaultAsync <TimeBlock>(); return(Timeblock); } }
/// <summary> /// Get all the Users in the database Async /// </summary> /// <returns>List of AppUser in Database</returns> public async Task <List <AppUser> > GetAppUsersAsync() { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var userList = await db.Users.ToListAsync <AppUser>(); return(userList); } }
/// <summary> /// Get all the TimeBlocks in the database async /// </summary> /// <returns></returns> public async Task <List <TimeBlock> > GetTimeBlocksAsync() { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeBlockList = await db.TimeBlocks.ToListAsync <TimeBlock>(); return(timeBlockList); } }
/// <summary> /// Create TimeBlocks Async /// </summary> /// <param name="timeBlock"></param> /// <returns> return true if success else false </returns> public async Task <bool> CreateNewTimeBlockRangeAsync(params TimeBlock[] timeBlocks) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { await db.TimeBlocks.AddRangeAsync(timeBlocks); return(db.SaveChanges() > 0); } }
/// <summary> /// Get all the Schedules in the database Async /// </summary> /// <returns></returns> public async Task <List <Schedule> > GetSchedulesAsync() { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var scheduleList = await db.Schedules.ToListAsync <Schedule>(); return(scheduleList); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { var db = new DailyTimeSchedulerDbContext(Configuration.GetSection("ConnectionString").GetSection("DbCon").Value); db.Database.Migrate();// do migration if (env.IsDevelopment()) { IdentityModelEventSource.ShowPII = true; app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseCookiePolicy(); app.UseJwtCookieMiddleware(app.ApplicationServices.GetService <IAntiforgery>(), Encoding.UTF8.GetBytes(Startup.StaticConfig.GetSection("SecurityKey1").Value)); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseAntiforgeryCookieMiddleware(app.ApplicationServices.GetService <IAntiforgery>()); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); }
/// <summary> /// Update exisiting app user's nickname using userNo to locate /// </summary> /// <param name="userNo"></param> /// <param name="newUserNickName"></param> /// <returns> return true if success else false </returns> public bool UpdateAppUserNickNameByNo(int userNo, string newUserNickName) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var userRecord = db.Users.Where(user => user.No == userNo).FirstOrDefault(); if (userRecord == null) { return(false); } userRecord.NickName = newUserNickName; return(db.SaveChanges() > 0); } }
/// <summary> /// Delete TimeBlock using TimeBlock no /// </summary> /// <param name="no"></param> /// <returns>True if Deletion is Sccuess else false </returns> public bool DeleteTimeBlockByNo(int no) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeBlock = db.TimeBlocks.Where(timeBlock => timeBlock.No == no).FirstOrDefault(); if (timeBlock == null) { return(false); } db.TimeBlocks.Remove(timeBlock); return(db.SaveChanges() > 0); } }
/// <summary> /// Update TimeBlock's RepeatPeriod by timeblock number /// </summary> /// <returns> return true if success else false </returns> public bool UpdateTimeBlockRepeatPeriodByNo(int timeBlockNo, long repeatPeriod) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeBlockRecord = db.TimeBlocks.Where(timeBlock => timeBlock.No == timeBlockNo).FirstOrDefault(); if (timeBlockRecord == null) { return(false); } timeBlockRecord.RepeatPeriod = repeatPeriod; return(db.SaveChanges() > 0); } }
/// <summary> /// Update EndUTCTime using timeBlockNo /// </summary> /// <returns> return true if success else false </returns> public bool UpdateIsAllDayByNo(int timeBlockNo, bool isAllDay) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var timeBlockRecord = db.TimeBlocks.Where(timeBlock => timeBlock.No == timeBlockNo).FirstOrDefault(); if (timeBlockRecord == null) { return(false); } timeBlockRecord.IsAllDay = isAllDay; return(db.SaveChanges() > 0); } }
/// <summary> /// Update exisiting app user's password using user Id to locate /// </summary> /// <param name="userId"></param> /// <param name="newUserPassword"></param> /// <returns>True if Success else false </returns> public bool UpdateAppUserPasswordById(string userId, string newUserPassword) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var userRecord = db.Users.Where(user => user.Id == userId).FirstOrDefault(); if (userRecord == null) { return(false); } userRecord.Password = newUserPassword; return(db.SaveChanges() > 0); } }
/// <summary> /// Delete an exisiting app user by userNo (unique key) /// </summary> /// <param name="userNo"></param> /// <returns>True if Success else false </returns> public bool DeleteAppUserByNo(int userNo) { using (var db = new DailyTimeSchedulerDbContext(_connectionString)) { var userRecord = db.Users.Where(user => user.No == userNo).FirstOrDefault(); if (userRecord == null) { return(false); } db.Users.Remove(userRecord); return(db.SaveChanges() > 0); } }