Пример #1
0
        public ActionResult RequestResources()
        {
            DistributerRequestViewModel model = new DistributerRequestViewModel();

            model.Resources = (from item in resourceRepo.FilteredGetAll()
                               select new AddressViewModel
            {
                Id = item.Id,
                Name = item.Name
            }
                               ).ToList();
            return(View(model));
        }
Пример #2
0
        public async Task <ActionResult> RequestResources(DistributerRequestViewModel model)
        {
            System.Security.Claims.ClaimsPrincipal currentUserClaims = this.User;
            var currentUser = await _userManager.GetUserAsync(currentUserClaims);

            int regionId   = (int)userRepo.FilteredGet().Where(x => x.Id == currentUser.Id).FirstOrDefault().RegionId;
            var newRequest = new DistributerRequests
            {
                RegionId    = regionId,
                ResourceId  = model.ResourceId,
                TotalNeeded = model.TotalNeeded
            };

            distributerRequestRepo.Insert(newRequest);
            return(RedirectToActionPermanent("Index"));
        }