Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!_isChanged)
                {
                    return;
                }

                if (!ValidateModel())
                {
                    return;
                }

                SetModel();

                if (_isAddNewMode)
                {
                    _userInformation.Id = _userInformationService.Insert(_userInformation);
                }
                else
                {
                    _userInformationService.Update(_userInformation);
                }

                LoadDataGridView();
                _currentIndex = _userInformationList.FindIndex(r => r.Id == _userInformation.Id);
                LoadFormWithData();
                MessageBox.Show(POSText.SaveMessage, MessageBoxCaptions.Success.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                MessageBox.Show(POSText.ErrorMessage, MessageBoxCaptions.Error.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        /// <summary>
        /// Edit user profile Post
        /// </summary>

        public ActionResult EditProfile(EditUserInformation information, HttpPostedFileBase uploadImage)
        {
            UserInformationEntity profile = null;

            try
            {
                profile = _informationServiceService.GetByUserId(_userService.GetUserByName(User.Identity.Name).Id);
            }
            catch
            {
                return(RedirectToAction("Error", "Error"));
            }

            byte[] imageData = null;

            using (var binaryReader = new BinaryReader(uploadImage.InputStream))
            {
                imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
            }

            profile.Avatar    = imageData;
            profile.FirstName = information.FirstName ?? profile.FirstName;
            profile.LastName  = information.LastName ?? profile.LastName;
            profile.Age       = information.Age == 0 ? profile.Age : information.Age;

            _informationServiceService.Update(profile);
            return(RedirectToAction("ShowProfile", new { userName = User.Identity.Name }));
        }
        public async Task <IActionResult> PostUserInfo(UserInfoDto userInfoDto)
        {
            var userId             = GetUserId();
            var updatedUserInfoDto = await _userInformationService.Update(userId, userInfoDto);

            await _unitOfWork.Commit();

            return(Ok(updatedUserInfoDto));
        }
Exemple #4
0
 public JsonResult Save([Bind(Include = "Id, UserTypeId, EmployeeId, RoleId, Username, Password, PasswordAgeLimit, IsPasswordChanged, IsLocked, WrongPasswordTryLimit, IsSuperAdmin, IsActive")] UserInformationModel userInformation, bool isInsert)
 {
     if (isInsert)
     {
         userInformation.SetCreateProperties(LoginInformation.UserInformation.Id);
         userInformation.Id = _userInformationService.Insert(userInformation);
     }
     else
     {
         userInformation.SetUpdateProperties(LoginInformation.UserInformation.Id);
         _userInformationService.Update(userInformation);
     }
     return(new JsonResult {
         Data = _userInformationService.GetById(userInformation.Id)
     });
 }
        public void StoreUserImage(User user, IFormFile image)
        {
            if (image != null && user?.UserInformation != null)
            {
                var imagePathSection = _configuration.GetSection("ImagePath");
                //string imgFolder = Path.Combine(_hostingEnvironment.WebRootPath, "img");
                //string avatarFolder = Path.Combine(imgFolder, "avatar");
                string avatarFolder   = imagePathSection["AvatarDirectory"];
                string uniqueFileName = Guid.NewGuid().ToString() + "_" + image.FileName;
                string filePath       = Path.Combine(avatarFolder, uniqueFileName);

                image.CopyTo(new FileStream(filePath, FileMode.Create));

                user.UserInformation.ImagePath = uniqueFileName;
                _userInformationService.Update(user.UserInformation);
            }
        }
        public async Task <IActionResult> EditProfile(ProfileEditViewModel model)
        {
            User user = await _userService.GetAsync(model.Id);

            UserInformation uinfo = user.UserInformation;

            uinfo.FirstName    = model.FirstName;
            uinfo.SecondName   = model.SecondName;
            uinfo.Birthday     = model.Birthday;
            uinfo.City         = model.City;
            uinfo.Gender       = model.Gender;
            uinfo.PlaceOfStudy = model.PlaceOfStudy;
            uinfo.PlaceOfWork  = model.PlaceOfWork;
            uinfo.AboutMyself  = model.AboutMyself;
            uinfo.Status       = model.Status;
            _imageService.StoreUserImage(user, model.Image);
            _userInformationService.Update(uinfo);
            return(RedirectToAction("Index", "Profile", new { id = model.Id }));
        }