public async Task <IActionResult> Profile()
        {
            var loggedUser = await userManager.GetUserAsync(User);

            var activeRoll = rollsService.GetActiveRoll();

            var user = new UsersProfileUser
            {
                Id              = loggedUser.Id,
                PhoneNumber     = loggedUser.PhoneNumber,
                Email           = loggedUser.Email,
                IsAdministrator = await userManager.IsInRoleAsync(loggedUser, Roles.Administrator)
            };

            var lastContactMessages = this.usersService.GetLastContactMessages <UsersProfileContactMessage>();

            var viewModel = new UsersProfileViewModel
            {
                HasActiveRoll   = activeRoll != null,
                User            = user,
                ContactMessages = lastContactMessages
            };

            return(this.View(viewModel));
        }
Example #2
0
        public IActionResult Edit(UsersProfileViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var fileUpload  = new FileUpload(env);
            var imageFile   = fileUpload.UploadFile(model.ProfileImage);
            var editedModel = new UsersEditViewModel
            {
                Id           = model.Id,
                UserName     = model.UserName,
                FirstName    = model.FirstName,
                MiddleName   = model.MiddleName,
                LastName     = model.LastName,
                Email        = model.Email,
                Address      = model.Address,
                PhoneNumber  = model.PhoneNumber,
                ProfileImage = imageFile
            };
            var updateModel = this.mapper.Map <UsersUpdateDto>(editedModel);

            this.usersService.UpdateUser(updateModel);
            this.usersService.Save();
            return(RedirectToAction(nameof(Profile), new { id = this.User.FindFirstValue(ClaimTypes.NameIdentifier) }));
        }
        public ActionResult Edit(UsersProfileViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    viewModel.UpdatedBy = User.UserID;
                    _userService.UpdateUserProfileByUserID(viewModel);

                    return(RedirectToAction("Index", "Dashboard", new { Area = "Admin" }));
                }
                viewModel.WorkTitleList = _userService.GetWorkTitles(0).Select(x => new SelectListItem
                {
                    Value    = x.ID.ToString(),
                    Text     = x.WorkTitle,
                    Selected = x.ID.Equals(viewModel.WorkTitleID)
                }).ToList();
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();
                return(View(viewModel));
            }
            catch (Exception cEx)
            {
                ModelState.AddModelError("", cEx.Message);
                return(View());
            }
        }
        public static UsersProfile ToEntity(this UsersProfileViewModel model, UsersProfile destination)
        {
            if (model == null)
            {
                return(destination);
            }

            //destination.Id = model.Id;
            destination.UserID            = model.UserID;
            destination.FirstName         = model.FirstName;
            destination.MiddleName        = model.MiddleName;
            destination.LastName          = model.LastName;
            destination.WorkTitleID       = model.WorkTitleID;
            destination.DisplayID         = model.DisplayID;
            destination.Gender            = model.Gender;
            destination.DOB               = model.DOB;
            destination.MartialStatus     = model.MartialStatus;
            destination.Address           = model.Address;
            destination.City              = model.City;
            destination.State             = model.State;
            destination.ZipCode           = model.ZipCode;
            destination.Country           = model.Country;
            destination.Mobile            = model.Mobile;
            destination.OtherEmailAddress = model.OtherEmailAddress;
            destination.IsActive          = model.IsActive;
            destination.CreatedBy         = model.CreatedBy;
            destination.UpdatedBy         = model.UpdatedBy;
            destination.CreatedDate       = model.CreatedDate;
            destination.UpdatedDate       = model.UpdatedDate;

            return(destination);
        }
        // mappings to PatientInsurance entity to Role view model


        public static UsersProfileViewModel ToModel(this UsersProfile entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new UsersProfileViewModel()
            {
                UserID            = entity.UserID,
                FirstName         = entity.FirstName,
                MiddleName        = entity.MiddleName,
                LastName          = entity.LastName,
                WorkTitleID       = entity.WorkTitleID,
                DisplayID         = entity.DisplayID,
                Gender            = entity.Gender,
                DOB               = entity.DOB,
                MartialStatus     = entity.MartialStatus,
                Address           = entity.Address,
                City              = entity.City,
                State             = entity.State,
                ZipCode           = entity.ZipCode,
                Country           = entity.Country,
                Mobile            = entity.Mobile,
                OtherEmailAddress = entity.OtherEmailAddress,
                IsActive          = entity.IsActive,
                CreatedBy         = entity.CreatedBy,
                UpdatedBy         = entity.UpdatedBy,
                CreatedDate       = entity.CreatedDate,
                UpdatedDate       = entity.UpdatedDate
            };

            return(model);
        }
Example #6
0
 public UsersProfilePage(UsersProfileViewModel profile)
 {
     InitializeComponent();
     this.BindingContext = new UsersProfileViewModel(this);
     ViewModel           = profile;
     this.BindingContext = ViewModel;
 }
        public static UsersProfile ToEntity(this UsersProfileViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new UsersProfile();

            return(ToEntity(model, entity));
        }
Example #8
0
 public void UpdateUserProfileByUserID(UsersProfileViewModel usersProfile)
 {
     try
     {
         _context.ups_UsersProfile_UpdateByUserID(usersProfile.UserID, usersProfile.FirstName, usersProfile.MiddleName,
                                                  usersProfile.LastName, usersProfile.WorkTitleID, usersProfile.DOJ, usersProfile.DisplayID, usersProfile.Gender, usersProfile.DOB, usersProfile.MartialStatus,
                                                  usersProfile.Address, usersProfile.City, usersProfile.State, usersProfile.ZipCode, usersProfile.Country,
                                                  usersProfile.Mobile, usersProfile.OtherEmailAddress, usersProfile.UpdatedBy);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public ActionResult Edit(UsersProfileViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    viewModel.UserID    = User.UserID;
                    viewModel.UpdatedBy = User.UserID;
                    _userService.UpdateUserProfileByUserID(viewModel);

                    return(RedirectToAction("Index", "Dashboard", new { Area = "Admin" }));
                }
                return(View(viewModel));
            }
            catch (Exception cEx)
            {
                ModelState.AddModelError("", cEx.Message);
                return(View());
            }
        }
Example #10
0
        public UsersProfileViewModel GetUserProfileByUserID(Guid UserId)
        {
            UsersProfileViewModel _userProfle = new UsersProfileViewModel();

            try
            {
                ups_UsersProfile_GetByUserID_Result vUserProfle = _context.ups_UsersProfile_GetByUserID(UserId).FirstOrDefault();
                if (vUserProfle != null)
                {
                    _userProfle.UserID            = vUserProfle.UserID;
                    _userProfle.FirstName         = vUserProfle.FirstName;
                    _userProfle.MiddleName        = vUserProfle.MiddleName;
                    _userProfle.LastName          = vUserProfle.LastName;
                    _userProfle.WorkTitleID       = vUserProfle.WorkTitleID;
                    _userProfle.WorkTitle         = vUserProfle.WorkTitle;
                    _userProfle.DOJ               = vUserProfle.DOJ;
                    _userProfle.DisplayID         = vUserProfle.DisplayID;
                    _userProfle.Gender            = vUserProfle.Gender;
                    _userProfle.DOB               = vUserProfle.DOB;
                    _userProfle.MartialStatus     = vUserProfle.MartialStatus;
                    _userProfle.Address           = vUserProfle.Address;
                    _userProfle.City              = vUserProfle.City;
                    _userProfle.State             = vUserProfle.State;
                    _userProfle.ZipCode           = vUserProfle.ZipCode;
                    _userProfle.Country           = vUserProfle.Country;
                    _userProfle.Mobile            = vUserProfle.Mobile;
                    _userProfle.OtherEmailAddress = vUserProfle.OtherEmailAddress;
                    _userProfle.IsActive          = vUserProfle.IsActive;
                    _userProfle.CreatedBy         = vUserProfle.CreatedBy;
                    _userProfle.UpdatedBy         = vUserProfle.UpdatedBy;
                    _userProfle.CreatedDate       = vUserProfle.CreatedDate;
                    _userProfle.UpdatedDate       = vUserProfle.UpdatedDate;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(_userProfle);
        }
Example #11
0
        public IActionResult Profile(string id)
        {
            var user = this.usersService.GetUserById(id);

            ViewData["ProfileImage"] = user.ProfileImage;
            var orders        = this.ordersService.GetAllOrders().Include(o => o.OrderProducts).ThenInclude(op => op.Product).Where(o => o.UserId == id).ToList();
            var userViewModel = new UsersProfileViewModel
            {
                Id          = user.Id,
                UserName    = user.UserName,
                FirstName   = user.FirstName,
                MiddleName  = user.MiddleName,
                LastName    = user.LastName,
                Email       = user.Email,
                Address     = user.Address,
                PhoneNumber = user.PhoneNumber,
                Orders      = orders
            };

            return(this.View(userViewModel));
        }
        public IActionResult <UsersProfileViewModel> Profile(int id)
        {
            using (var db = new NotesDbContext())
            {
                UsersProfileViewModel viewModel = db.Users
                                                  .Where(u => u.Id == id)
                                                  .Select(u => new UsersProfileViewModel
                {
                    UserId   = u.Id,
                    Username = u.Username,
                    Notes    = u.Notes
                               .Select(
                        n => new NoteViewModel()
                    {
                        Title   = n.Title,
                        Content = n.Content
                    })
                }).FirstOrDefault();

                return(View(viewModel));
            }
        }
Example #13
0
        public ActionResult Edit()
        {
            try
            {
                UsersProfileViewModel viewModel = new UsersProfileViewModel();
                viewModel = _userService.GetUserProfileByUserID(User.UserID);

                viewModel.WorkTitleList = _userService.GetWorkTitles(0).Select(x => new SelectListItem
                {
                    Value    = x.ID.ToString(),
                    Text     = x.WorkTitle,
                    Selected = x.ID.Equals(viewModel.WorkTitleID)
                }).ToList();

                return(View(viewModel));
            }
            catch (Exception cEx)
            {
                ModelState.AddModelError("", cEx.Message);
                return(View());
            }
        }
Example #14
0
        public async Task <HttpResponseMessage> UpdateUserProfile(int userId, [FromBody] UsersProfileViewModel userProfile)
        {
            var oldUserProfile = mapper.Map <Users>(userProfile);

            oldUserProfile.Password = EncryptionLibrary.EncryptText(oldUserProfile.Password);
            if (await _userProfile.UpdateUserProfileAsync(oldUserProfile))
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.NoContent
                };
                return(response);
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };
                return(response);
            }
        }
Example #15
0
        public ActionResult Edit(Guid?UserID)
        {
            try
            {
                Guid userID = (!string.IsNullOrWhiteSpace(UserID.ToString())) ? UserID.Value : User.UserID;
                if (userID != Guid.Empty)
                {
                    UsersProfileViewModel viewModel = new UsersProfileViewModel();
                    viewModel = _userService.GetUserProfileByUserID(userID);

                    viewModel.WorkTitleList = _userService.GetWorkTitles(0).Select(x => new SelectListItem
                    {
                        Value    = x.ID.ToString(),
                        Text     = x.WorkTitle,
                        Selected = x.ID.Equals(viewModel.WorkTitleID)
                    }).ToList();

                    if (viewModel.UserID == Guid.Empty)
                    {
                        return(RedirectToAction("NotFound", "Error", new { Area = "" }));
                    }
                    else
                    {
                        return(View(viewModel));
                    }
                }
                else
                {
                    return(RedirectToAction("NotFound", "Error", new { Area = "" }));
                }
            }
            catch (Exception cEx)
            {
                ModelState.AddModelError("", cEx.Message);
                return(View());
            }
        }