Esempio n. 1
0
        public async Task <IActionResult> Edit(int id)
        {
            UserType userType = await _userTypeManager.FindById(id);

            UserTypeUpdateDto userTypeUpdate = _mapper.Map <UserTypeUpdateDto>(userType);

            return(View(userTypeUpdate));
        }
        public async Task <IActionResult> UpdateUserType(UserTypeUpdateDto updatedUserType)
        {
            ServiceResponse <UserTypeGetDto> response = await _userTypeService.UpdateUserType(updatedUserType);

            if (response.Data == null)
            {
                return(NotFound(response));
            }

            return(Ok(response));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(UserTypeUpdateDto model)
        {
            if (ModelState.IsValid)
            {
                UserType userType = await _userTypeManager.FindById(model.UserTypeId);

                userType = _mapper.Map <UserType>(model);
                await _userTypeManager.UpdateAsync(userType);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public async Task <ServiceResponse <UserTypeGetDto> > UpdateUserType(UserTypeUpdateDto updatedUserType)
        {
            ServiceResponse <UserTypeGetDto> serviceResponse = new ServiceResponse <UserTypeGetDto>();

            try{
                UserType userType = await _context.UserTypes.FirstOrDefaultAsync(u => u.id == updatedUserType.id);

                userType.id          = updatedUserType.id;
                userType.type        = updatedUserType.type;
                userType.accessLevel = updatedUserType.accessLevel;

                _context.UserTypes.Update(userType);
                await _context.SaveChangesAsync();

                serviceResponse.Data = _mapper.Map <UserTypeGetDto>(userType);
            }
            catch (Exception ex) {
                serviceResponse.Success = false;
                serviceResponse.Message = ex.Message;
            }
            return(serviceResponse);
        }