コード例 #1
0
        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));
        }
コード例 #2
0
        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"));
        }