public override Boolean SetWeeklySchedule(int index, DateTime dt, string sc, int weekSpan)
 {
     if (!IfPowerful())
     {
         return(false);
     }
     using (var db = new ScheduleContext())
     {
         var weeklySchedules = from s in db.WeeklySchedules
                               where s.UserQQ == GroupQQ && s.UserType == 1
                               orderby s.ScheduleTime
                               select s;
         var weeklySchedule = weeklySchedules.ToList().ElementAt(index);
         if (weeklySchedule != null)
         {
             weeklySchedule.ScheduleTime    = dt;
             weeklySchedule.ScheduleContent = sc;
             weeklySchedule.WeekSpan        = weekSpan;
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 //删除群日程需要权限
 public override Boolean DelSchedule(int index)
 {
     if (!IfPowerful())
     {
         return(false);
     }
     using (var db = new ScheduleContext())
     {
         var schedules = from s in db.Schedules
                         where s.UserQQ == GroupQQ && s.UserType == 1
                         orderby s.ScheduleTime
                         select s;
         var schedule = schedules.ToList().ElementAt(index);
         if (schedule != null)
         {
             db.Schedules.Remove(schedule);
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
     loggerFactory.AddConsole(Configuration.GetSection("Logging"));
     loggerFactory.AddDebug();
     app.UseCors("AllowAllOrigins");
     ScheduleContext.UpdateDatabase(app);
     //app.UseStaticFiles();
     app.UseMvc();
 }
 //给日程提醒开的所有日程的接口
 public static List <Schedule> GetGlobalSchedules()
 {
     using (var db = new ScheduleContext())
     {
         var schedules = from s in db.Schedules
                         select s;
         return(schedules.ToList());
     }
 }
 public static List <WeeklySchedule> GetGlobalWeeklySchedules()
 {
     using (var db = new ScheduleContext())
     {
         var weeklySchedules = from s in db.WeeklySchedules
                               select s;
         return(weeklySchedules.ToList());
     }
 }
示例#6
0
 public override bool AddSchedule(DateTime dt, string sc)
 {
     using (var db = new ScheduleContext())
     {
         Schedule schedule = new Schedule(QQ, 0, dt, sc);
         db.Schedules.Add(schedule);
         db.SaveChanges();
         return(true);
     }
 }
示例#7
0
 public override bool AddWeeklySchedule(DateTime dt, string sc, int weekSpan)
 {
     using (var db = new ScheduleContext())
     {
         WeeklySchedule weeklySchedule = new WeeklySchedule(QQ, 0, dt, sc, weekSpan);
         db.WeeklySchedules.Add(weeklySchedule);
         db.SaveChanges();
         return(true);
     }
 }
示例#8
0
 public override List <Schedule> GetSchedules()
 {
     using (var db = new ScheduleContext())
     {
         var schedules = from s in db.Schedules
                         where s.UserQQ == QQ && s.UserType == 0
                         orderby s.ScheduleTime
                         select s;
         return(schedules.ToList());
     }
 }
 public override List <WeeklySchedule> GetWeeklySchedules()
 {
     using (var db = new ScheduleContext())
     {
         var weeklySchedules = from s in db.WeeklySchedules
                               where s.UserQQ == GroupQQ && s.UserType == 1
                               orderby s.ScheduleTime
                               select s;
         return(weeklySchedules.ToList());
     }
 }
 //增加群日程需要权限
 public override Boolean AddSchedule(DateTime dt, string sc)
 {
     if (!IfPowerful())
     {
         return(false);
     }
     using (var db = new ScheduleContext())
     {
         Schedule schedule = new Schedule(GroupQQ, 1, dt, sc);
         db.Schedules.Add(schedule);
         db.SaveChanges();
         return(true);
     }
 }
 public override Boolean AddWeeklySchedule(DateTime dt, string sc, int weekSpan)
 {
     if (!IfPowerful())
     {
         return(false);
     }
     using (var db = new ScheduleContext())
     {
         WeeklySchedule weeklySchedule = new WeeklySchedule(GroupQQ, 1, dt, sc, weekSpan);
         db.WeeklySchedules.Add(weeklySchedule);
         db.SaveChanges();
         return(true);
     }
 }
示例#12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ScheduleContext db)
        {
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            if (env.IsDevelopment())
            {
                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();
            }

            db.Database.Migrate();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
        }
示例#13
0
 public override bool DelWeeklySchedule(int index)
 {
     using (var db = new ScheduleContext())
     {
         var weeklySchedules = from s in db.WeeklySchedules
                               where s.UserQQ == QQ && s.UserType == 0
                               orderby s.ScheduleTime
                               select s;
         var weeklySchedule = weeklySchedules.ToList().ElementAt(index);
         if (weeklySchedule != null)
         {
             db.WeeklySchedules.Remove(weeklySchedule);
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
示例#14
0
 public override bool SetSchedule(int index, DateTime dt, string sc)
 {
     using (var db = new ScheduleContext())
     {
         var schedules = from s in db.Schedules
                         where s.UserQQ == QQ && s.UserType == 0
                         orderby s.ScheduleTime
                         select s;
         var schedule = schedules.ToList().ElementAt(index);
         if (schedule != null)
         {
             schedule.ScheduleTime    = dt;
             schedule.ScheduleContent = sc;
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
示例#15
0
 public Repository(ScheduleContext context)
 {
     this.context = context;
     entities     = context.Set <T>();
 }
示例#16
0
 public UnitOfWork(ScheduleContext context)
 {
     _context = context;
 }
示例#17
0
        public static void SeedData(ScheduleContext context)
        {
            if (!context.Availability.Any())
            {
                context.Availability.AddRange(
                    new Availability
                {
                    Name = "Numerator"
                },
                    new Availability
                {
                    Name = "Denominator"
                },
                    new Availability
                {
                    Name = "Both"
                }
                    );
            }
            context.SaveChanges();
            if (!context.Faculties.Any())
            {
                context.Faculties.AddRange(
                    new Faculty
                {
                    Name = "Faculty of Foreign Languages"
                },
                    new Faculty
                {
                    Name = "Faculty of Physics"
                },
                    new Faculty
                {
                    Name = "Faculty of Applied Mathematics and Informatics"
                },
                    new Faculty
                {
                    Name = "Faculty of Biology"
                },
                    new Faculty
                {
                    Name = "Faculty of Chemistry"
                },
                    new Faculty
                {
                    Name = "Faculty of Culture and Arts"
                },
                    new Faculty
                {
                    Name = "Faculty of Economics"
                },
                    new Faculty
                {
                    Name = "Faculty of Geography"
                },
                    new Faculty
                {
                    Name = "Faculty of Geology"
                },
                    new Faculty
                {
                    Name = "Faculty of History"
                },
                    new Faculty
                {
                    Name = "Faculty of International Relations"
                },
                    new Faculty
                {
                    Name = "Faculty of Journalism"
                },
                    new Faculty
                {
                    Name = "Faculty of Law"
                },
                    new Faculty
                {
                    Name = "Faculty of Mechanics and Mathematics"
                });
            }
            context.SaveChanges();

            if (!context.Groups.Any())
            {
                context.Groups.AddRange(
                    new Group
                {
                    Name      = "PMP51",
                    FacultyId = 3
                },
                    new Group
                {
                    Name      = "PMP52",
                    FacultyId = 3
                },
                    new Group
                {
                    Name      = "PMA51",
                    FacultyId = 3
                },
                    new Group
                {
                    Name      = "PMA52",
                    FacultyId = 3
                },
                    new Group
                {
                    Name      = "PMI51",
                    FacultyId = 3
                },
                    new Group
                {
                    Name      = "PMI52",
                    FacultyId = 3
                },
                    new Group
                {
                    Name      = "PMI53",
                    FacultyId = 3
                }

                    );
            }
            context.SaveChanges();
            if (!context.Lessons.Any())
            {
                context.Lessons.AddRange(
                    new Lesson
                {
                    Number = 1,
                    Hour   = 8,
                    Minute = 30
                },
                    new Lesson
                {
                    Number = 2,
                    Hour   = 10,
                    Minute = 10
                },
                    new Lesson
                {
                    Number = 3,
                    Hour   = 11,
                    Minute = 50
                },
                    new Lesson
                {
                    Number = 4,
                    Hour   = 13,
                    Minute = 30
                },
                    new Lesson
                {
                    Number = 5,
                    Hour   = 15,
                    Minute = 5
                }
                    );
            }
            context.SaveChanges();
            if (!context.Rooms.Any())
            {
                context.Rooms.AddRange(
                    new Room
                {
                    Name = "265"
                },
                    new Room
                {
                    Name = "111"
                },
                    new Room
                {
                    Name = "266"
                },
                    new Room
                {
                    Name = "439"
                },
                    new Room
                {
                    Name = "118"
                },
                    new Room
                {
                    Name = "116"
                },
                    new Room
                {
                    Name = "119a"
                },
                    new Room
                {
                    Name = "119b"
                }
                    );
            }
            context.SaveChanges();

            if (!context.Semesters.Any())
            {
                context.Semesters.AddRange(
                    new Semester
                {
                    Number = 1,
                    //StartDate = new DateTime(2020, 09, 01,0,0,0,DateTimeKind.Utc),
                    //EndDate = new DateTime(2020, 12, 31, 0, 0, 0, DateTimeKind.Utc)
                    StartDate = new DateTime(2020, 9, 1),
                    EndDate   = new DateTime(2020, 12, 31)
                }
                    //new Semester
                    //{
                    //    Number = 2,
                    //    StartDate = new DateTime(2021, 02, 11, 0, 0, 0, DateTimeKind.Utc),
                    //    EndDate = new DateTime(2021, 06, 31, 0, 0, 0, DateTimeKind.Utc)
                    //}
                    );
            }
            context.SaveChanges();

            if (!context.Subjects.Any())
            {
                context.Subjects.AddRange(
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Algebra and Geometry"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Discrete Mathematics"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Algorithms for Computing Processes "
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Mathematical Analysis"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Basics of Programming"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "History of Ukrainian Culture"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "History of Ukraine"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Architecture of Computer Systems"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Object Oriented Programming"
                },
                    new Subject
                {
                    FacultyId = 3,
                    Name      = "Equations of Mathematical Physics"
                }
                    );
            }
            context.SaveChanges();
            if (!context.Teachers.Any())
            {
                context.Teachers.AddRange(
                    new Teacher
                {
                    FirstName = "Ivan",
                    LastName  = "Dyyak",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Ivan",
                    LastName  = "Dyyak",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Olha",
                    LastName  = "Kovalchuk",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Vitaliy ",
                    LastName  = "Horlatch",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Andrii",
                    LastName  = "Melnychyn",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Yarema",
                    LastName  = "Savula",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Vasyl",
                    LastName  = "Biletskyj",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Yuriy",
                    LastName  = "Yashchuk",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Roman",
                    LastName  = "Chapko",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Ihor",
                    LastName  = "Mukha",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                },
                    new Teacher
                {
                    FirstName = "Mykhaylo",
                    LastName  = "Shcherbatyy",
                    FacultyId = 3,
                    Reference = "*****@*****.**"
                });
            }
            context.SaveChanges();

            if (!context.Schedule.Any())
            {
                context.Schedule.AddRange(
                    new Models.Schedule
                {
                    NumberDay      = 1,
                    TeacherId      = 1,
                    SubjectId      = 1,
                    RoomId         = 1,
                    LessonId       = 1,
                    GroupId        = 1,
                    SemesterId     = 1,
                    AvailabilityId = 1
                },
                    new Models.Schedule
                {
                    NumberDay      = 1,
                    TeacherId      = 2,
                    SubjectId      = 2,
                    RoomId         = 1,
                    LessonId       = 2,
                    GroupId        = 2,
                    SemesterId     = 1,
                    AvailabilityId = 3
                },
                    new Models.Schedule
                {
                    NumberDay      = 1,
                    TeacherId      = 3,
                    SubjectId      = 3,
                    RoomId         = 3,
                    LessonId       = 3,
                    GroupId        = 4,
                    SemesterId     = 1,
                    AvailabilityId = 2
                },
                    new Models.Schedule
                {
                    NumberDay      = 2,
                    TeacherId      = 4,
                    SubjectId      = 4,
                    RoomId         = 2,
                    LessonId       = 1,
                    GroupId        = 3,
                    SemesterId     = 1,
                    AvailabilityId = 2
                },
                    new Models.Schedule
                {
                    NumberDay      = 2,
                    TeacherId      = 5,
                    SubjectId      = 5,
                    RoomId         = 4,
                    LessonId       = 2,
                    GroupId        = 5,
                    SemesterId     = 1,
                    AvailabilityId = 3
                },
                    new Models.Schedule
                {
                    NumberDay      = 2,
                    TeacherId      = 6,
                    SubjectId      = 6,
                    RoomId         = 5,
                    LessonId       = 3,
                    GroupId        = 6,
                    SemesterId     = 1,
                    AvailabilityId = 2
                },
                    new Models.Schedule
                {
                    NumberDay      = 2,
                    TeacherId      = 7,
                    SubjectId      = 7,
                    RoomId         = 6,
                    LessonId       = 4,
                    GroupId        = 7,
                    SemesterId     = 1,
                    AvailabilityId = 2
                },
                    new Models.Schedule
                {
                    NumberDay      = 2,
                    TeacherId      = 8,
                    SubjectId      = 8,
                    RoomId         = 7,
                    LessonId       = 5,
                    GroupId        = 2,
                    SemesterId     = 1,
                    AvailabilityId = 3
                },
                    new Models.Schedule
                {
                    NumberDay      = 3,
                    TeacherId      = 9,
                    SubjectId      = 9,
                    RoomId         = 4,
                    LessonId       = 1,
                    GroupId        = 3,
                    SemesterId     = 1,
                    AvailabilityId = 1
                },
                    new Models.Schedule
                {
                    NumberDay      = 4,
                    TeacherId      = 10,
                    SubjectId      = 10,
                    RoomId         = 5,
                    LessonId       = 3,
                    GroupId        = 4,
                    SemesterId     = 1,
                    AvailabilityId = 3
                }
                    );
            }
            context.SaveChanges();
        }