Exemplo n.º 1
0
        public virtual ActionResult Create(UserProfile userprofile)
        {
            if (ModelState.IsValid)
            {
                userprofile.Password = MD5Hashing.MD5Hash(userprofile.Password);
                _userProfileService.AddUserProfile(userprofile);
                return(Json(new { success = true }));
            }

            ViewBag.UserProfileID = new SelectList(_userRoleService.GetAllUserRole(), "UserRoleID", "UserRoleID", userprofile.UserProfileID);
            return(PartialView("Users/Create", userprofile));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> PostUserProfile(UserProfileReceivingDTO userProfileReceiving)
        {
            var response = await _userProfileService.AddUserProfile(userProfileReceiving);

            if (response.StatusCode >= 400)
            {
                return(StatusCode(response.StatusCode, response));
            }
            var user = ((ApiOkResponse)response).Result;

            return(Ok((UserProfileTransferDTO)user));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> UpdateProfile(UserProfileReceivingDTO userProfileReceivingDTO)
        {
            var response = await userProfileService.AddUserProfile(userProfileReceivingDTO);

            if (response.StatusCode >= 400)
            {
                return(StatusCode(response.StatusCode, response));
            }

            var user        = ((ApiOkResponse)response).Result;
            var userProfile = (UserProfileTransferDTO)user;

            var token = GenerateToken(userProfile);
            UserAuthTransferDTO userAuthTransferDTO = new UserAuthTransferDTO()
            {
                Token       = token,
                UserProfile = userProfile
            };

            return(Ok(userAuthTransferDTO));
        }