public InstructorModule(UniContext context) : base("/instructor", context) { After += ctx => { UpdateUserCache(ctx.Request.Method, ModifiedItem); }; }
public async Task EditInstanceAsync(Course model, UniContext ctx, CancellationToken token) { Name = model.Name; Code = model.Code; Ects = model.Ects; Program = await ctx.Programs.FindAsync(token, model.Program.Id); }
public StudentModule(UniContext context) : base("/student", context) { After += ctx => { UpdateUserCache(ctx.Request.Method, ModifiedItem); }; }
public FuncionariosController(UniContext context, UserManager <IdentityUser> userManager, IEmailSender emailSender, RoleManager <IdentityRole> roleManager) { _context = context; _userManager = userManager; _emailSender = emailSender; _roleManager = roleManager; }
public StudentActionModule(UniContext context) : base("/student", typeof(Student)) { this.context = context; Post("/register", RegisterSectionAsync); Post("/unregister", UnregisterSectionAsync); Get("/sections/registered", GetRegisteredSectionsAsync); Get("/courses", GetAvailableCoursesAsync); Get("/grades", GetGradesAsync); }
// Delete book public void delete(string strBookID) { using (var context = new UniContext()) { var book = context.Books.Where(x => x.BookID.ToString().Equals(strBookID)).Single(); context.Books.Remove(book); context.SaveChanges(); } }
// Edit book public void Edit(string strBookID) { using (var context = new UniContext()) { var book = context.Books.Where(x => x.BookID.ToString().Equals(strBookID)).Single(); book.BookName = "BookEdit"; context.SaveChanges(); } }
public async Task EditInstanceAsync(Student model, UniContext ctx, CancellationToken token) { EditInstance(model); StudentId = model.StudentId; Semester = model.Semester; Year = model.Year; Cgpa = model.Cgpa; Program = await ctx.Programs.FindAsync(token, model.Program.Id); }
public InstructorActionModule(UniContext context) : base("/instructor", typeof(Instructor)) { this.context = context; Get("/sections", GetSectionsAsync); Get("/section/{id}/students", GetSectionStudentsAsync); Get("/gradetypes/{id}", GetGradeTypesAsync); Post("/gradetypes/{id}", SetGradeTypesAsync); Get("/grades/{id}", GetStudentGradesAsync); Post("/grade/{id}", SetStudentGradeAsync); }
public async Task EditInstanceAsync(Section model, UniContext ctx, CancellationToken token) { Number = model.Number; Capacity = model.Capacity; Course = await ctx.Courses.FindAsync(token, model.Course.Id); Instructor = await ctx.Instructors.FindAsync(token, model.Instructor.Id); TimeTable.Clear(); TimeTable.AddRange(model.TimeTable); }
/// <summary> /// Loads configuration data from json file. /// </summary> /// <param name="workingDirectory">Path to config.json directory</param> public static void Init(string workingDirectory = "") { var configJson = File.ReadAllText(workingDirectory + "config.json"); dynamic config = JsonConvert.DeserializeObject(configJson); string connType = config.DbType; string dbname = config.DbName; string srvname = config.ServerName; string userid = config.UserId; string password = config.Password; //This switch statement binds a return function for each of the different possible database connections switch (connType.ToUpper()) { case "MYSQL": var connectionString = new MySqlConnectionStringBuilder { Database = dbname, UserID = userid, Password = password, Server = srvname }.ConnectionString; GetDbConnection = () => new MySqlConnection(connectionString);; break; case "MSSQL": connectionString = new SqlConnectionStringBuilder { DataSource = srvname, InitialCatalog = dbname, UserID = userid, Password = password }.ConnectionString; GetDbConnection = () => new SqlConnection(connectionString); break; case "LOCALDB": connectionString = dbname; GetDbConnection = () => new LocalDbConnectionFactory("mssqllocaldb").CreateConnection(connectionString); break; } AppKey = config.AppKey; HostUri = config.HostUri; LogFileName = config.LogFileName; using (var context = new UniContext()) { context.Database.CreateIfNotExists(); } UserCache.Reload(); }
public StudentController(UniContext context) // dependency injection of SudentRepo class instance { this.context = context; if (context.Students.Count() == 0) { // Create a new TodoItem if collection is empty, // which means you can't delete all TodoItems. foreach (var item in studs) { context.Students.Add(item); } context.SaveChanges(); } }
/// <summary> /// Reloads the list of all users. /// </summary> public static void Reload() { if (Users == null) { Users = new List <User>(); } else { Users.Clear(); } using (var context = new UniContext()) { Users.AddRange(context.Admins.ToList()); Users.AddRange(context.Instructors.ToList()); Users.AddRange(context.Students.ToList()); } }
protected CrudModule(string uri, UniContext context) : base(uri, typeof(Admin)) { propVal = new string[2]; this.context = context; Get("/", GetItemsAsync); Get("/with/{props}", GetItemsWithPropsAsync); Get("/where/{prop}={value}", GetItemsWherePropAsync); Get("/where/{prop}={value}/with/{props}", GetItemsWherePropWithPropsAsync); Get("/range/{value1}-{value2}", GetItemsRangeAsync); Get("/range/{value1}-{value2}/with/{props}", GetItemsRangeWithPropsAsync); Get("/range/{prop}={value1}-{value2}", GetItemsRangePropAsync); Get("/range/{prop}={value1}-{value2}/with/{props}", GetItemsRangePropWithPropsAsync); Get("/{id}", GetItemByIdAsync); Get("/{id}/with/{props}", GetItemByIdWithPropsAsync); Post("/", AddItemAsync); Put("/{id}", EditItemAsync); Delete("/{id}", DeleteItemAsync); }
// Add new book public void Add() { using (var context = new UniContext()) { var book = new Book { BookID = "BK00000001", BookName = "FullStack React", Tags = "React", Publisher = "FullStack.io", Authors = "FullStack.io", Pages = 678, Size = 12.3 }; context.Books.Add(book); context.SaveChanges(); } }
/// <summary> /// Admin registration. /// Should be disabled once an admin is registered. /// </summary> /// <param name="_">Not used</param> /// <param name="token">Cancellation token if request is cancelled</param> /// <returns>User details in JSON format</returns> private async Task <object> RegisterAsync(dynamic _, CancellationToken token) { var data = Request.Form; using (var context = new UniContext()) { //Hashes password using BCrypt with work factor 8 string pw = await Task.Run(() => HashPassword(data.password, GenerateSalt(8)), token); var admin = context.Admins.Add(new Admin { Email = data.email, FirstName = data.firstname, LastName = data.lastname, Password = pw }); await context.SaveChangesAsync(token); UserCache.Users.Add(admin); return(Response.AsJson(admin)); } }
public HistoricoStatusController(UniContext context) { _context = context; }
public HistoricoSalariosController(UniContext context) { _context = context; }
public StudentController(StudentService studentService, UniContext context) { this.studentService = studentService; this.context = context; }
public async Task BindInstanceAsync(UniContext ctx, CancellationToken token) { }
public SectionModule(UniContext context) : base("/section", context) { }
public async Task BindInstanceAsync(UniContext ctx, CancellationToken token) { Program = await ctx.Programs.FindAsync(token, Program.Id); }
public async Task EditInstanceAsync(Admin model, UniContext ctx, CancellationToken token) { EditInstance(model); }
#pragma warning disable 1998 public async Task EditInstanceAsync(Department model, UniContext ctx, CancellationToken token) #pragma warning restore 1998 { Name = model.Name; }
public TelefonesController(UniContext context) { _context = context; }
public async Task BindInstanceAsync(UniContext ctx, CancellationToken token) { Department = await ctx.Departments.FindAsync(token, Department.Id); }
public async Task EditInstanceAsync(Instructor model, UniContext ctx, CancellationToken token) { EditInstance(model); InstructorId = model.InstructorId; Department = await ctx.Departments.FindAsync(token, model.Department.Id); }
public ClientesController(UniContext context) { _context = context; }
#pragma warning disable 1998 public async Task BindInstanceAsync(UniContext ctx, CancellationToken token) #pragma warning restore 1998 { }
public CotacaoProdutoesController(UniContext context) { _context = context; }