public IActionResult Edit(int id, Room room)
{
if (id != room.Id)
{
return(NotFound());
}
if (ModelState.IsValid)
{
room.Action = Actions.ActionUpdate;
room.ActionDate = DateTime.Now.ToString("F");
room.ActionBy = "Me";
room.IsDelete = 0;
string updated = roomManager.Update(room);
ViewData["Message"] = updated;
ModelState.Clear();
if (updated.Equals("1"))
{
return(RedirectToAction("Index"));
}
else
{
ViewData["Message"] = updated;
return(View(room));
}
}
else
{
ViewData["Message"] = Message.Warning("Fill up all fields correctly");
//get by id
Room roomModel = roomManager.GetById(room.Id);
return(View(roomModel));
}
}