private bool AddToResult(FindStorageView model, Storage storage) { bool addToResult = true; if (model.City == null && model.Street == null) { addToResult = false; } if (model.City != null && storage.City != model.City) { addToResult = false; } if (model.Street != null && storage.Street != model.Street) { addToResult = false; } return(addToResult); }
public IActionResult Find(FindStorageView model) { List <Storage> storages = new List <Storage>(); if (ModelState.IsValid) { var allStorages = unitOfWork.Storages.GetAll().ToList(); foreach (var storage in allStorages) { bool addToResult = true; if (model.City == null && model.Street == null) { addToResult = false; } if (model.City != null && storage.City != model.City) { addToResult = false; } if (model.Street != null && storage.Street != model.Street) { addToResult = false; } if (addToResult) { storages.Add(storage); } } HttpContext.Session.Set("list", storages); return(RedirectToAction("FindResult", "Storage")); } return(View(model)); }
public IActionResult Find(FindStorageView model) { List <Storage> storages = new List <Storage>(); if (ModelState.IsValid) { var allStorages = unitOfWork.Storages.GetAll().ToList(); foreach (var storage in allStorages) { if (this.AddToResult(model, storage)) { storages.Add(storage); } } HttpContext.Session.Set("list", storages); return(RedirectToAction("FindResult", "Storage")); } return(View(model)); }