public ActionResult UpdateCars(CarViewModel data) { try { if (Session["userId"] == null) { return(RedirectToAction("Login", "Account")); } manager = new StorageManager(UnitOfWork); // for updating the record if (new Guid(data.Id) != Guid.Empty) { Car objectCars = new Car() { Id = new Guid(data.Id), Brand = data.Brand, Model = data.Model, Year = data.Year, Price = data.Price, New = data.New, UserId = Convert.ToString(Session["userId"]) }; manager.AddCar(objectCars); } else { // for saving the record Car objectCars = new Car() { Id = Guid.NewGuid(), Brand = data.Brand, Model = data.Model, Year = data.Year, Price = data.Price, New = data.New, UserId = Convert.ToString(Session["userId"]) }; manager.AddCar(objectCars); } } catch (Exception ex) { // handling the error logger.Error(ex.ToString()); } return(RedirectToAction("Index")); }