public void Delete(Students student) { using (StudentsDBContext context = new StudentsDBContext()) { context.Students.Remove(student); context.SaveChanges(); } }
public void Add(Students model) { using (StudentsDBContext context = new StudentsDBContext()) { context.Students.Add(model); context.SaveChanges(); } }
public List <Students> getAll() { using (StudentsDBContext context = new StudentsDBContext()) { List <Students> all = context.Students.ToList(); return(all); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, StudentsDBContext context) { var genders = context.Genders.Any(); if (!genders) { context.Genders.Add(new Gender() { Description = "მდედრობითი" }); context.Genders.Add(new Gender() { Description = "მამრობითი" }); context.SaveChanges(); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseCors(x => x .SetIsOriginAllowed(origin => true) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public StudentsDBController(StudentsDBContext context) { _context = context; }
public StudentService(StudentsDBContext studentsDBContext) { _context = studentsDBContext; }
public StudentController(StudentsDBContext context, IRepository repository) { _repository = repository; _context = context; }
public DB_AccountModels() { context = new StudentsDBContext(); }
public StudentModels() { context = new StudentsDBContext(); }
public Students Get(long id) { using (StudentsDBContext context = new StudentsDBContext()) return(context.Students.FirstOrDefault(s => s.StudentId == id)); }