public ActionResult Edit(int id)
        {
            var managerDto = _managerService.GetManagerById(id);

            if (managerDto != null)
            {
                var model = new ManagerEditModel
                {
                    Id       = managerDto.Id,
                    LastName = managerDto.LastName
                };
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
Example #2
0
        private ManagerEditModel convertToManagerEditModel(FullManagerViewModel manager, List <Country> allCountries, List <int> selectedCountries)
        {
            ManagerEditModel managerEditModel = new ManagerEditModel()
            {
                Id          = manager.Id,
                FirstName   = manager.FirstName,
                LastName    = manager.LastName,
                DateOfBirth = manager.DateOfBirth.Date,
                PhoneNumber = manager.PhoneNumber,
                Email       = manager.Email,
                Password    = manager.Password
            };

            managerEditModel.Countries = getCountries(allCountries, selectedCountries);
            return(managerEditModel);
        }
 public ActionResult Edit(ManagerEditModel model)
 {
     if (ModelState.IsValid)
     {
         var managerDto = new ManagerDto
         {
             Id       = model.Id,
             LastName = model.LastName
         };
         var operationDetails = _managerService.Edit(managerDto);
         if (operationDetails.Succedeed)
         {
             return(RedirectToAction("Index"));
         }
         ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
     }
     return(View(model));
 }
Example #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var manager = await _applicationDbContext.Managers
                          .Include(m => m.Users)
                          .SingleOrDefaultAsync(m => m.Id == id.Value);

            if (manager == null)
            {
                return(NotFound());
            }

            ManagerEditModel      = ManagerEditModel.Parse(manager);
            ManagerUserEditModels = manager.Users.Select(mu => new ManagerUserEditModel(mu)).ToList();

            return(Page());
        }
Example #5
0
        public async Task <IActionResult> OnPostManagerEditAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var manager = _applicationDbContext.Managers
                          .Include(m => m.Users)
                          .SingleOrDefault(m => m.Id == ManagerEditModel.Id);

            if (manager == null)
            {
                return(NotFound());
            }

            manager = ManagerEditModel.MapToManager(manager);

            _applicationDbContext.Managers.Update(manager);
            await _applicationDbContext.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IViewComponentResult> InvokeAsync(ManagerEditModel manager)
        {
            await Task.Delay(0);

            return(View("Edit", manager));
        }