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);
     }
 }
Exemple #4
0
        // 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();
            });
        }
Exemple #5
0
 public StudentsDBController(StudentsDBContext context)
 {
     _context = context;
 }
 public StudentService(StudentsDBContext studentsDBContext)
 {
     _context = studentsDBContext;
 }
Exemple #7
0
 public StudentController(StudentsDBContext context, IRepository repository)
 {
     _repository = repository;
     _context    = context;
 }
Exemple #8
0
 public DB_AccountModels()
 {
     context = new StudentsDBContext();
 }
Exemple #9
0
 public StudentModels()
 {
     context = new StudentsDBContext();
 }
 public Students Get(long id)
 {
     using (StudentsDBContext context = new StudentsDBContext())
         return(context.Students.FirstOrDefault(s => s.StudentId == id));
 }