public ActionResult RequestResource() { var model = new DistrictRequestListViewModel(); model.Resources = (from item in resourceRepo.FilteredGet() select new AddressViewModel { Id = item.Id, Name = item.Name }).ToList(); return(View(model)); }
public async System.Threading.Tasks.Task <ActionResult> RequestResource(DistrictRequestListViewModel model) { System.Security.Claims.ClaimsPrincipal currentUserClaims = this.User; var currentUser = await _userManager.GetUserAsync(currentUserClaims); var regionId = (int)userRepo.FilteredGet().Where(x => x.Id == currentUser.Id).FirstOrDefault().RegionId; int cityId = (int)regionRepo.FilteredGet().Where(x => x.Id == regionId).FirstOrDefault().CityId; var data = new CityRequests { CityId = cityId, ResourceId = model.ResourceId, TotalNeeded = model.TotalNeeded }; CityRequestsRepo.Insert(data); return(RedirectToActionPermanent("Index")); }