Exemple #1
0
 public async Task <IActionResult> Get()
 {
     using (DbStudentsContext db = new DbStudentsContext())
     {
         return(Ok(await db.Vehicles.ToListAsync()));
     }
 }
Exemple #2
0
 public async Task <IActionResult> GetByUser(int id)
 {
     using (DbStudentsContext db = new DbStudentsContext())
     {
         return(Ok(await db.Vehicles.Where(i => i.IdOwner == id).ToListAsync()));
     }
 }
        public async Task <IActionResult> Get(int id)
        {
            using (DbStudentsContext db = new DbStudentsContext())
            {
                var owner = await db.Owners.FindAsync(id);

                return(Ok(owner));
            }
        }
Exemple #4
0
        public async Task <IActionResult> Get(int id)
        {
            using (DbStudentsContext db = new DbStudentsContext())
            {
                var vehicle = await db.Vehicles.FindAsync(id);

                return(Ok(vehicle));
            }
        }
Exemple #5
0
        public async Task <IActionResult> Get()
        {
            using (DbStudentsContext db = new DbStudentsContext())
            {
                var peoples = await db.Peoples.ToListAsync();

                return(Ok(peoples));
            }
            //return new string[] { "value1", "value2" };
        }
Exemple #6
0
 public async Task <IActionResult> Get()
 {
     using (DbStudentsContext db = new DbStudentsContext())
     {
         return(Ok(await db.PenaltyFees
                   .Include(i => i.Owner)
                   .Include(i => i.Vehicle)
                   .ToListAsync()));
     }
 }
 public async Task <IActionResult> Get([FromQuery] string identification)
 {
     using (DbStudentsContext db = new DbStudentsContext())
     {
         return(Ok(await db.Owners
                   .Where(i => string.IsNullOrEmpty(identification) || i.Identification.Equals(identification))
                   .Include(i => i.Penalties)
                   .Include(i => i.Vehicles)
                   .ToListAsync()));
     }
 }
Exemple #8
0
        public async Task <IActionResult> PayPenalty(int id)
        {
            using (DbStudentsContext db = new DbStudentsContext())
            {
                var penalty = await db.PenaltyFees.FindAsync(id);

                penalty.State = false;

                db.Update(penalty);

                await db.SaveChangesAsync();

                return(Ok());
            }
        }
        public async Task <IActionResult> Post([FromBody] Owner data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            using (DbStudentsContext db = new DbStudentsContext())
            {
                var result = await db.AddAsync(data);

                await db.SaveChangesAsync();

                var path = new Uri(HttpContext.Request.Path);
                return(Created(path, data.Id));
            }
        }
Exemple #10
0
        public async Task <IActionResult> Post([FromBody] People data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            using (DbStudentsContext db = new DbStudentsContext())
            {
                var result = await db.AddAsync(data);

                await db.SaveChangesAsync();

                //        msg.Headers.Location = new Uri(Request.RequestUri + newCust.ID.ToString());

                var path = new Uri(HttpContext.Request.Path);
                return(Created(path, data.Id));
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              DbStudentsContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            app.UseAuthentication();


            /*app.UseCors(
             *  options => options.WithOrigins("*").AllowAnyMethod()
             * );*/
            app.UseCors("CorsPolicy");

            app.UseMvc();
            app.Use(async(context, next) => {
                await next();
                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("/api/"))
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });

            app.UseMvcWithDefaultRoute();
            app.UseDefaultFiles();
            app.UseStaticFiles();

            //Create Tables
            dbContext.Database.EnsureCreated();
        }