public async Task <ActionResult <string> > PostMeasure([FromBody] Measurement measure) { _logger.LogInformation($"Humedad: {measure.Humidity.ToString()}"); _logger.LogInformation($"Temperatura: {measure.Temperature.ToString()}"); Ripening currentRipening = await _ripeningServices.GetCurrentRipening(); if (currentRipening == null) { return(StatusCode(412, "There is no active ripening")); } measure.DateTime = DateTime.Now; currentRipening.Measurements.Add(measure); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } //Check if current measure is in accepted deviation _ripeningServices.ValidateMeasure(measure); return(Created("measure", measure)); }
public async Task <IActionResult> AccountsEdit(int id, [Bind("Id,Voornaam,Achternaam,Geslacht,Geboortedatum,Email,Wachtwoord,Confirmwachtwoord,Telnummer,Huisnummer,Straatnaam,Postcode,Activatiecode,Geactiveerd")] Klant klant) { if (id != klant.Id) { return(NotFound()); } // if(ModelState.IsValid){ try { _context.Update(klant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KlantExists(klant.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Accounts))); // } // return View(klant); }
public async Task <IActionResult> PutCheese(Guid id, Cheese cheese) { if (id != cheese.Id) { return(BadRequest()); } _context.Entry(cheese).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CheeseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Soort,Aantal,Naam,Prijs")] Winkelwagen item) { if (ModelState.IsValid) { _context.Add(item); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Winkelwagen))); } return(View(item)); }
public async Task <IActionResult> Create([Bind("Id,UserName,Score,Comment,KaasName")] Rating rating) { if (ModelState.IsValid) { _context.Add(rating); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Rating))); } return(View(rating)); }
public async Task <IActionResult> EndCurrentExperiment() { Experiment experiment = await _experimentServices.GetCurrentExperiment(); if (experiment == null) { return(StatusCode(412, "There is no active experiment")); } experiment.EndTime = DateTime.Now; _context.Experiments.Update(experiment); await _context.SaveChangesAsync(); return(Ok(experiment)); }
public async Task <IActionResult> Product(int id, [Bind("Id,Naam,Merk,Melksoort,Vet,Biologisch,Kaassoort,Eetbarekorst,Afkomst,Prijs,Afbeelding,Beschrijving,Winkelwagen,Aantal,Favorieten,Voorraad")] Kaas kaas) { if (id != kaas.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(kaas); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KaasExists(kaas.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Product))); } return(View(kaas)); }