コード例 #1
0
        public IActionResult EditStop([FromForm] FuelStop stop)
        {
            var existingStop = Database.Stops.FirstOrDefault(b => b.id == stop.id);

            existingStop.stopDate          = stop.stopDate.Date;
            existingStop.stopAmount        = stop.stopAmount;
            existingStop.price             = stop.price;
            existingStop.distanceTravelled = stop.distanceTravelled;

            Database.Stops.Update(existingStop);
            Database.SaveChanges();

            return(RedirectToAction("index"));
        }
コード例 #2
0
        public IActionResult AddFuelStop([FromForm] AddStopRequest stopRequest)
        {
            var newStop = new FuelStop();

            // newStop.stopDate = DateTime.UtcNow;
            newStop.stopDate          = stopRequest.stopDate.Date;
            newStop.stopAmount        = stopRequest.stopAmount;
            newStop.price             = stopRequest.price;
            newStop.distanceTravelled = stopRequest.distanceTravelled;

            Database.Stops.Add(newStop);
            Database.SaveChanges();

            return(RedirectToAction("index"));
        }