public async Task <IActionResult> Create([FromForm] ParkingAreaViewModel model) { _repo.Create(_mapper.Map <ParkingArea>(model)); if (await _repo.SaveAsync()) { return(RedirectToAction("Parkings", "Home")); } _logger.LogError($"Failed to add new parking {model.Moniker}"); return(BadRequest()); }
public ActionResult Index(string destination, string DateTimeFrom, string ToTimeFrom) { var lat = string.Empty; var lng = string.Empty; bool flag; string FDateTime = "0"; string TDateTime = "0"; string strOrderBy = "Space_Type"; if (destination == string.Empty || DateTimeFrom == string.Empty || ToTimeFrom == string.Empty || DateTimeFrom == null) { if (destination == string.Empty) { lat = "0"; lng = "0"; } else { GetLatLongByLocation(destination, ref lat, ref lng); } if ((DateTimeFrom != string.Empty && DateTimeFrom != null) || (ToTimeFrom != string.Empty && ToTimeFrom != null)) { FDateTime = DateTimeFrom; TDateTime = ToTimeFrom; } ParkingAreaViewModel vm = new ParkingAreaViewModel { Distance = Convert.ToInt32(ConfigurationManager.AppSettings["Searchdistance"].ToString()), FromDateTime = FDateTime, ToDateTime = TDateTime, ParkingClass = "PC_A", Main_Latitude = decimal.Parse(lat), Main_Longitude = decimal.Parse(lng), OrderBy = strOrderBy }; TempData["ParkingAreaViewModel"] = vm; return(RedirectToAction("Index", "ParkingArea", vm)); } else { GetLatLongByLocation(destination, ref lat, ref lng); ParkingAreaViewModel vm = new ParkingAreaViewModel { Distance = Convert.ToInt32(ConfigurationManager.AppSettings["Searchdistance"].ToString()), FromDateTime = DateTimeFrom, ToDateTime = ToTimeFrom, ParkingClass = "PC_A", Main_Latitude = decimal.Parse(lat), Main_Longitude = decimal.Parse(lng), }; TempData["ParkingAreaViewModel"] = vm; // flag = saveVisitorHistory(DateTimeFrom, null, destination, null); return(RedirectToAction("Index", "ParkingArea", vm)); } }