Esempio n. 1
0
        public ActionResult CreateAUser(UserViewModels user)
        {
            IUserFacade        customerFacade    = (IUserFacade)FacadeFactory.Instance.Create(FacadeType.UserFacade);
            IUserDTO           createCustomerDTO = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO);
            HttpPostedFileBase file = Request.Files["ImageData"];

            user.IdentityProof = convertToBytes(file);
            if (ModelState.IsValid)
            {
                DTOConverter.FillDTOFromViewModel(createCustomerDTO, user);
                OperationResult <IUserDTO> resultCreate = customerFacade.CreateAUser(createCustomerDTO);
                if (resultCreate.IsValid())
                {
                    return(View("../Home/Index"));
                }

                else
                {
                    IList <AdminPortalValidationFailure> resultFail = resultCreate.ValidationResult.Errors;
                    foreach (var item in resultFail)
                    {
                        ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                    }
                    return(View());
                }
            }
            return(View());
        }