I want to have parking available system. So I have boolean variable which is Status. And I set default variable is true. It means parking slot is available.
After added data Status is false. But it doesn't work. It still save same data. How can I have control system for available or not?
This is my model
public Boolean Status { get; set; } = true;
This is my if else control
if (obj.Status == true)
{
_db.Bookings.Add(obj);
obj.Status = false;
_db.SaveChanges();
TempData["success"] = "Booking created successfully";
}
else
{
TempData["error"] = "This slot is already booked for " + obj.PickHours + " hours";
return RedirectToAction("Index");
}
return View(obj);