public Silos fabriciranje2([FromForm] int id, [FromForm] int inkrement) { var silos = dbcontext.Silosi.FirstOrDefault(x => x.Id == id); silos.TrenKolicina += inkrement; dbcontext.SaveChanges(); return(silos); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PekaraDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); var Fabrika = new Fabrika() { Naziv = "Pajina fabrika" }; var Silos1 = new Silos() { Fabrika = Fabrika, Kapacitet = 1000, Oznaka = "Pajin prvi silos", TrenKolicina = 420 }; var Silos2 = new Silos() { Fabrika = Fabrika, Kapacitet = 2000, Oznaka = "Pajin drugi silos", TrenKolicina = 1080 }; context.Silosi.Add(Silos1); context.Silosi.Add(Silos2); context.Fabrike.Add(Fabrika); Fabrika = new Fabrika() { Naziv = "Pajina fabrika 2" }; Silos1 = new Silos() { Fabrika = Fabrika, Kapacitet = 1000, Oznaka = "Pajin prvi silos 2", TrenKolicina = 420 }; Silos2 = new Silos() { Fabrika = Fabrika, Kapacitet = 2000, Oznaka = "Pajin drugi silos 2", TrenKolicina = 1080 }; context.Silosi.Add(Silos1); context.Silosi.Add(Silos2); context.Fabrike.Add(Fabrika); context.SaveChanges(); }