public ActionResult AddorEdit(Booking booking) { if (ModelState.IsValid && Session["user"] != null) { var customer = (Customer)Session["user"]; booking.CustomerId = customer.Id; if (booking.Id != 0) { booking.UpdatedBy = customer.Name; booking.UpdatedOn = DateTime.Now; } else { booking.CreatedBy = customer.Name; booking.CreatedOn = DateTime.Now; booking.UpdatedBy = customer.Name; booking.UpdatedOn = DateTime.Now; } var vehicle = _serviceManager.GetVehicle(booking.VehicleId); var vehicleMake = vehicle.Make; var mechanic = _serviceManager.GetMechanicByMake(vehicleMake); if (mechanic != null) { booking.MechanicId = mechanic.Id; } var result = _serviceManager.AddBooking(booking); TempData["SuccessMessage"] = "Booking added successfully"; MyLogger.GetInstance().Info("Booking added successfully"); return(RedirectToAction("Index")); } TempData["ErrorMessage"] = " Booking does not added"; MyLogger.GetInstance().Info("Booking does not added"); return(RedirectToAction("Index", "Home")); }