public async Task <ActionResult> EditPassword(ProfileVM profileVM, string oldPass)
        {
            using (var profile = new ChekitDB())
            {
                var modelDTO = new ProfileDTO()
                {
                    UsersProfileDTO = await profile.Users.FirstOrDefaultAsync(x => x.UserId == profileVM.UserInfo.UserId)
                };

                if (oldPass != modelDTO.UsersProfileDTO.Password)
                {
                    ModelState.AddModelError("oldPassError", "Старый пароль указан не верно");

                    return(View(profileVM));
                }

                modelDTO.UsersProfileDTO.Password = profileVM.UserInfo.Password;

                await profile.SaveChangesAsync();

                TempData["OK"] = "Пароль успешно изменен";

                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 2
0
        private void createUserConfirmationEmail(string id)
        {
            EmailClient email = EmailClient.Create();

            var user = DAL.Context.Users.Where(x => x.Id == id).Select(x => new { Email = x.Email, Profile = x.Profile }).FirstOrDefault();

            if (user?.Profile == null)
            {
                return;
            }

            string phoneNumber = user.Profile.PhoneNumber?.PadLeft(10, ' ') ?? "          ";

            ProfileVM vm = new ProfileVM {
                Id            = id,
                Name          = user.Profile.FullName,
                Address       = user.Profile.Address,
                City          = user.Profile.City,
                State         = user.Profile.State,
                Zip           = user.Profile.Zip,
                DeliveryNotes = user.Profile.DeliveryNotes,

                RedditUsername  = user.Profile.RedditUsername,
                UntappdUsername = user.Profile.UntappdUsername,

                References = user.Profile.References,
                //Wishlist = user.Profile.Wishlist,
                Comments = user.Profile.Comments,

                Piney  = user.Profile.Piney,
                Juicy  = user.Profile.Juicy,
                Tart   = user.Profile.Tart,
                Funky  = user.Profile.Funky,
                Malty  = user.Profile.Malty,
                Roasty = user.Profile.Roasty,
                Sweet  = user.Profile.Sweet,
                Smokey = user.Profile.Smokey,
                Spicy  = user.Profile.Spicy,
                Crisp  = user.Profile.Crisp,


                Phone = $"{phoneNumber.Substring(0, 3)}-{phoneNumber.Substring(3, 3)}-{phoneNumber.Substring(6, 4)}",
                Email = user.Email,

                UpdateDate = user.Profile.UpdateDate
            };

            string body = "<p>Thanks for updating your profile. Here's what we have on record for you:</p>" + RenderPartialToString(this, "__ViewProfile", vm);

            MailMessage message = new MailMessage {
                To         = { new MailAddress(user.Email, user.Profile.FullName) },
                Bcc        = { new MailAddress("*****@*****.**"), new MailAddress("*****@*****.**") },
                From       = new MailAddress("*****@*****.**", "BeerItForward"),
                Subject    = "BeerItForward Profile Complete",
                Body       = body,
                IsBodyHtml = true
            };

            email.SMTP.Send(message);
        }
        public ActionResult Index(ProfileVM model)
        {
            string msg = "";

            if (ModelState.IsValid)
            {
                bool success = _pRepo.EditProfile(model, out msg);
                if (success)
                {
                    if (msg == ProfileRepo.USERNAME_UPDATED)
                    {
                        // log off user when username/email has been updated successfully
                        HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                        return(RedirectToAction("Index", "Home"));
                    }
                    TempData["SuccessMsg"] = msg;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["ErrorMsg"] = msg;
                    // to do, add the list if fails
                }
            }
            // get the dropdown list
            model.SendMethodList = _selectListRepo.GetSendMethodList();
            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult UserProfile()
        {
            if (Session["loggedUser"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            UserDTO user = (UserDTO)Session["loggedUser"];

            Service1Client service = new Service1Client();

            List <UserToBookDTO> books = service.GetBooksByUserId(user.Id).ToList();

            List <FriendDTO> friends = service.GetFriendsByUserId(user.Id).ToList();

            ProfileVM profile = new ProfileVM()
            {
                Id        = user.Id,
                Username  = user.Username,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Email     = user.Email,
                Role      = user.userRole.RoleName,
                DOB       = user.DOB,
                isOnline  = user.isOnline,
                Books     = books,
                Friends   = friends
            };


            return(View(profile));
        }
Ejemplo n.º 5
0
 public ActionResult Edit(ProfileVM profileVM)
 {
     try
     {
         using (DMSDBContext dc = new DMSDBContext())
         {
             string message  = "";
             var    validate = dc.Departments.Where(a => a.DeptName == profileVM.DeptName).FirstOrDefault();
             if (validate == null)
             {
                 var data = dc.Departments.Where(x => x.DeptId == profileVM.DeptId).FirstOrDefault();
                 data.DeptName        = profileVM.DeptName;
                 data.DeptId          = profileVM.DeptId;
                 dc.Entry(data).State = EntityState.Modified;
                 dc.SaveChanges();
                 message             = "Department Edited Successfully";
                 TempData["Message"] = message;
                 return(RedirectToAction("Index", "Department"));
             }
             else
             {
                 message             = "This Department is already created. Please use another!!";
                 TempData["Message"] = message;
                 return(RedirectToAction("Create", "Department"));
             }
         }
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> changeEmail([Bind(Include = "EditEmail")] ProfileVM model, string oldEmail)
        {
            // User.Identity.GetUserId();
            var y = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(View("~/Views/ApplicationUsers/changeEmail.cshtml", model));
            }

            var store       = new UserStore <ApplicationUser>(new ApplicationDbContext());
            var manager     = new UserManager <ApplicationUser>(store);
            var currentUser = manager.FindById(y);

            currentUser.Email = model.EditEmail.Email;
            await manager.UpdateAsync(currentUser);

            var ctx = store.Context;

            ctx.SaveChanges();

            TempData["msg"] = "Email Changes Saved please Check inbox to confirem new " + model.EditEmail.Email;

            return(PartialView("~/Views/ApplicationUsers/changeEmail.cshtml", model));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }

            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ProfileVM.Parse(getOperation.Result);

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Edit", Controller = "Profiles", Icon = "fa-edit", Text = "Edit"
            });

            ViewData["Title"]       = "Edit profile";
            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Ejemplo n.º 8
0
        public ActionResult Edit(ProfileVM vm)
        {
            string userEmail = GetUserEmail();

            if (String.IsNullOrEmpty(userEmail) || userEmail != vm.User.Email)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (!vm.User.IsNickNameValid())
            {
                return(RedirectToAction("Index", "Home"));
            }


            var editUser = db.Users.SingleOrDefault(x => x.Email == vm.User.Email);

            vm.User.FirstName = vm.User.FirstName ?? "";
            vm.User.LastName  = vm.User.LastName ?? "";

            editUser.FirstName = vm.User.FirstName;
            editUser.LastName  = vm.User.LastName;
            editUser.NickName  = vm.User.NickName;

            db.SaveChanges();

            return(RedirectToAction("Profile", "User"));
        }
Ejemplo n.º 9
0
 public Profile()
 {
     InitializeComponent();
     ProfileVM = new ProfileVM();
     ProfileVM.PropertyChanged += viewModelPropertyChanged;
     myGrid.DataContext         = ProfileVM;
 }
Ejemplo n.º 10
0
        // get user profile detail to display for "GET" method
        public ProfileVM GetUserDetail(IPrincipal User)
        {
            if (User != null)
            {
                var       username    = User.Identity.Name;
                string    referenceID = _context.UserDetail.Where(u => u.User.UserName == username).SingleOrDefault().ReferenceID;
                ProfileVM user        = _context.UserDetail
                                        .Where(u => u.ReferenceID == referenceID)
                                        .Select(a => new ProfileVM
                {
                    ReferenceID   = a.ReferenceID,
                    BusinessPhone = a.BusinessPhone,
                    BusinessTitle = a.BusinessTitle,
                    FirstName     = a.FirstName,
                    Email         = a.User.Email,
                    LastName      = a.LastName,
                    HomePhone     = a.HomePhone,
                    MobilePhone   = a.MobilePhone,
                    SendMethodID  = a.SendMethodID
                }).FirstOrDefault();

                return(user);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 11
0
        public ActionResult Profile(string user)
        {
            if (Session[SessionKey.UserId] == null)
            {
                return(new HttpNotFoundResult());
            }
            var usr = UserDAO.GetUserFromUsername(user);

            if (usr == null)
            {
                return(new HttpNotFoundResult());
            }

            var vm = ProfileVM.ModelToVm(usr);

            if (Session[SessionKey.UserId] != null && Equals(Session[SessionKey.UserId], usr.Id))
            {
                vm.IsOwner = true;
            }
            else if (Session[SessionKey.UserId] != null && usr.Friends.Any(f => f.Id == (Guid)Session[SessionKey.UserId]))
            {
                vm.IsFriend = true;
            }
            return(View(vm));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Index(ProfileVM profile)
        {
            var user = userRepository.GetUserById(userManager.GetUserId(User));

            if (user.UserId != userManager.GetUserId(User))
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(View(profile));
            }

            try
            {
                user.User.FirstName = profile.UserProfileVM.FirstName;
                user.User.LastName  = profile.UserProfileVM.LastName;

                user.CompanyName = profile.UserProfileVM.CompanyName;
                user.JobTitle    = profile.UserProfileVM.JobTitle;
                user.AfterWords  = profile.UserProfileVM.AfterWords;
                user.Twitter     = profile.UserProfileVM.Twitter;

                userContext.Update(user);
                await userContext.SaveChangesAsync();

                return(RedirectToAction("Index", new RouteValueDictionary(
                                            new { controller = "User", action = "Index" })));
            }
            catch
            {
                return(View(profile));
            }
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> EditProfile(ProfileVM userVM)
        {
            if (ModelState.IsValid)
            {
                UserProfile UserDomain = Mapper.Map <ProfileVM, UserProfile>(userVM);
                using (var _context = new ApplicationDbContext())
                {
                    bool ValidUser = await _context.UserProfiles.Where(x => x.Id == UserDomain.Id).AnyAsync();

                    if (ValidUser)
                    {
                        _context.Entry(UserDomain).State = EntityState.Modified;
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        return(Json("fail", JsonRequestBehavior.AllowGet));
                    }
                }
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                ModelState.AddModelError("", "Model State Invalid!");
                return(View(userVM));
            }
        }
Ejemplo n.º 14
0
        public ActionResult ChangePassword(ProfileVM profileVM)
        {
            try
            {
                using (DMSDBContext dc = new DMSDBContext())
                {
                    string message = "";

                    var validate = dc.Users.Where(a => a.Password == profileVM.Password).FirstOrDefault();
                    if (validate != null)
                    {
                        validate.Password        = profileVM.NewPassword;
                        dc.Entry(validate).State = EntityState.Modified;
                        dc.SaveChanges();

                        message             = "Password Changed Successfully";
                        TempData["Message"] = message;
                        return(RedirectToAction("Index", "Profile"));
                    }
                    else
                    {
                        message = "Input Valid Current Password";
                    }
                    ViewBag.Message = message;
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 15
0
        public ActionResult EditProfile(ProfileVM myProfileVM)
        {
            User editedUser = (User)Session["CurrentUser"];
            bool isValid    = true;

            if (editedUser.Email != myProfileVM.Email)
            {
                if (!userService.IsEmailCorrect(myProfileVM.Email))
                {
                    ModelState.AddModelError("email", "Email is taken or not correct.");
                    isValid = false;
                }
            }

            if (ModelState.IsValid && isValid)
            {
                editedUser.Address   = myProfileVM.Address;
                editedUser.City      = myProfileVM.City;
                editedUser.Zipcode   = myProfileVM.Zipcode;
                editedUser.FirstName = myProfileVM.FirstName;
                editedUser.LastName  = myProfileVM.LastName;
                editedUser.Email     = myProfileVM.Email;

                userService.EditUser(editedUser);

                Session["CurrentUser"] = editedUser;
                TempData["message"]    = "Successfully edited profile: " + editedUser.Login;
                return(RedirectToAction("MyProfile"));
            }

            return(View(myProfileVM));
        }
Ejemplo n.º 16
0
        public ProfileVM GetProfile()
        {
            var user = UserService
                       .GetByPK(AuthService.CurrentUser.UserID);

            var manager     = OrderService.GetUserManagerTC(user);
            var existgroup  = OrderService.ExistGroup(user);
            var companyName = string.Empty;

            if (user.EmployeeCompanyID.HasValue)
            {
                companyName = CompanyService.GetValues(user.EmployeeCompanyID, x => x.CompanyName);
            }
            var result =
                new ProfileVM(Htmls.IsNewProfile)
            {
                User                = user,
                IsBest              = IsBest(user),
                IsExcelMaster       = IsExcelMaster(user),
                EmployeeCompanyName = companyName,
                Manager             = manager,
                HasUnlimit          = HasUnlimit(user),
                Videos              = VideoService.GetAll(x => x.IsActive).OrderByDescending(x => x.VideoID).Take(5).ToList(),
                ExistGroup          = existgroup
            };

            return(result);
        }
Ejemplo n.º 17
0
        public ActionResult UserProfile()
        {
            string    userName = this.User.Identity.Name;
            ProfileVM vm       = this.service.GetProfileVM(userName);

            return(this.View(vm));
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Index()
        {
            User user = await _userIdentity.GetCurrentAsync();

            if (user == null)
            {
                return(NotFound());
            }

            ProfileVM model = new ProfileVM()
            {
                EditProfileVM = new ProfileVM.EditProfileSubVM()
                {
                    FirstName    = user.FirstName,
                    LastName     = user.LastName,
                    EmailAddress = user.EmailAddress,
                    CurrentEmail = user.EmailAddress,
                    PhoneNumber  = user.PhoneNumber
                },
                EditPasswordVM    = new ProfileVM.EditPasswordSubVM(),
                EditPreferencesVM = new ProfileVM.EditPreferencesSubVM()
                {
                    Currency = user.Currency,
                    Theme    = user.Theme
                }
            };

            ViewData["SupportedCurrencies"] = new SelectList(_clientCurrency.Options.SupportedCurrencies, nameof(Currency.Code), nameof(Currency.Code));
            ViewData["SupportedThemes"]     = new SelectList(_clientTheme.Options.SupportedThemes, nameof(Theme.ID), nameof(Theme.DisplayName));
            ViewData["UserFullName"]        = $"{user.FirstName} {user.LastName}";
            return(View(model));
        }
Ejemplo n.º 19
0
 public ActionResult Delete(int id, ProfileVM profileVM)
 {
     try
     {
         using (DMSDBContext dc = new DMSDBContext())
         {
             int    uid  = Convert.ToInt32(Session["id"]);
             var    data = dc.Documents.Where(x => x.DocumentId == id).FirstOrDefault();
             string strPhysicalFolder = Server.MapPath("//Documents/" + data.Category.CategoryName + "/");
             string strFileFullPath   = strPhysicalFolder + data.DocumentName;
             if (System.IO.File.Exists(strFileFullPath))
             {
                 System.IO.File.Delete(strFileFullPath);
                 dc.Documents.Remove(data);
                 dc.SaveChanges();
             }
             string message = "Document Deleted Successfully";
             TempData["Message"] = message;
             return(RedirectToAction("Index", "Document"));
         }
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 20
0
        public async Task <IActionResult> EditPassword(ProfileVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(Index), model));
            }

            int?userId = _userIdentity.GetCurrentId();

            if (userId == null)
            {
                return(NotFound());
            }

            if (await _users.UpdateUserPassword(userId.Value, model.EditPasswordVM.CurrentPassword, model.EditPasswordVM.NewPassword))
            {
                TempData["SuccessTitle"] = "Password Changed";
                TempData["SuccessBody"]  = "Your password has been changed successfully.";
            }
            else
            {
                TempData["EditPassword_ErrorMessage"] = "Current password is incorrect.";
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> Edit(Guid id, ProfileVM vm)
        {
            if (ModelState.IsValid)
            {
                var getOperation = await _bo.ReadAsync(id);

                if (!getOperation.Success)
                {
                    return(OperationErrorBackToIndex(getOperation.Exception));
                }

                if (getOperation.Result == null)
                {
                    return(RecordNotFound());
                }

                var result = getOperation.Result;

                if (!vm.CompareToModel(result))
                {
                    result = vm.ToProfile(result);

                    var updateOperation = await _bo.UpdateAsync(result);

                    if (!updateOperation.Success)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception);
                        return(View(vm));
                    }

                    return(OperationSuccess("The record was successfully updated."));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 22
0
        public ProfileVM GetProfileVM(string userName)
        {
            ApplicationUser currentUser    = this.Context.Users.FirstOrDefault(user => user.UserName == userName);
            ProfileVM       vm             = Mapper.Map <ApplicationUser, ProfileVM>(currentUser);
            Student         currentStudent = this.Context.Students.FirstOrDefault(student => student.User.Id == currentUser.Id);


            //doesnt work!
            //vm.EnrolledCourses = Mapper.Map<IEnumerable<Course>, IEnumerable<UserCourseVM>>(currentStudent.Courses);

            //
            //test second way filling the enrolled courses
            var           students        = this.Context.Students.ToArray();
            var           courses         = this.Context.Courses.ToList();
            List <Course> enrolledCourses = new List <Course>();

            for (int i = 0; i < courses.Count(); i++)
            {
                var studentsBuffer = courses[i].Students.ToArray();

                for (int j = 0; j < studentsBuffer.Count(); j++)
                {
                    if (studentsBuffer[j].User.Id.ToString() == currentUser.Id.ToString())
                    {
                        enrolledCourses.Add(courses[i]);
                    }
                }
            }

            //
            //test end
            vm.EnrolledCourses = Mapper.Map <IEnumerable <Course>, IEnumerable <UserCourseVM> >(enrolledCourses.AsEnumerable());
            return(vm);
        }
Ejemplo n.º 23
0
 public ActionResult Create(ProfileVM profileVM)
 {
     try
     {
         using (DMSDBContext dc = new DMSDBContext())
         {
             string message  = "";
             var    validate = dc.Departments.Where(a => a.DeptName == profileVM.DeptName).FirstOrDefault();
             if (validate == null)
             {
                 Department department = new Department();
                 department.DeptName = profileVM.DeptName;
                 dc.Departments.Add(department);
                 dc.SaveChanges();
                 message             = "Department Created Successfully";
                 TempData["Message"] = message;
                 return(RedirectToAction("Index", "Department"));
             }
             else
             {
                 message             = "This Department is already created. Please use another!!";
                 TempData["Message"] = message;
                 return(RedirectToAction("Create", "Department"));
             }
         }
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 24
0
        public async System.Threading.Tasks.Task <ActionResult> Profile(ProfileVM model)
        {
            if (ModelState.IsValid)
            {
                if (model.ChangePassword == true && (model.Password == null))
                {
                    ModelState.AddModelError("", "New Password is required");
                }
            }
            if (ModelState.IsValid)
            {
                if (model.ChangePassword)
                {
                    var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.CurrentPassword, model.CurrentPassword);

                    if (result.Succeeded)
                    {
                        var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                        if (user != null)
                        {
                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                        }
                        return(RedirectToAction("CertificateVerification", "Home", new { Message = ManageMessageId.ChangePasswordSuccess }));
                    }
                    AddErrors(result);
                }
            }

            return(View(model));
        }
Ejemplo n.º 25
0
        public string RenderViewAsString(string viewName, ProfileVM model)
        {
            try
            {
                // create a string writer to receive the HTML code
                StringWriter stringWriter = new StringWriter();

                // get the view to render
                ViewEngineResult viewResult = ViewEngines.Engines.FindView(ControllerContext, viewName, null);
                // create a context to render a view based on a model
                ViewContext viewContext = new ViewContext(
                    ControllerContext,
                    viewResult.View,
                    new ViewDataDictionary(model),
                    new TempDataDictionary(),
                    stringWriter
                    );

                // render the view to a HTML code
                viewResult.View.Render(viewContext, stringWriter);

                // return the HTML code
                return(stringWriter.ToString());
            }
            catch (Exception)
            {
                return("");
            }
        }
        //добавление ключевого слова
        public async Task <ActionResult> AddBlackListSite(string banWord)
        {
            ProfileVM profileVM = new ProfileVM();

            using (var profile = new ChekitDB())
            {
                BannedSiteDTO bannedSiteDTO = new BannedSiteDTO()
                {
                    SiteLink = banWord
                };

                profile.BannedSiteDTO.Add(bannedSiteDTO);

                await profile.SaveChangesAsync();

                var modelDTO = new ProfileDTO()
                {
                    BannedSiteListDTO = await profile.BannedSiteDTO.ToListAsync()
                };

                TempData["OK"] = "Имя ресурса добавлено";

                profileVM.BannedSiteVM = modelDTO.BannedSiteListDTO.OrderBy(x => x.SiteId).Select(x => new BannedSiteVM(x)).ToList();

                return(RedirectToAction("SiteBlackList"));
            }
        }
Ejemplo n.º 27
0
        public ActionResult Profile()
        {
            //ελέγχουμε αν υπάρχει κάποιος χρήστης που έχει κάνει login
            string userEmail = GetUserEmail();

            if (String.IsNullOrEmpty(userEmail))
            {
                return(RedirectToAction("Index", "Home"));
            }

            User user = db.Users.Single(x => x.Email == userEmail);

            db.InitUserChatGroups(user);

            db.InitFriends(user);
            foreach (var friend in user.Friends)
            {
                db.InitUserChatGroups(friend);
            }

            db.InitRequests(user);

            ProfileVM vm = new ProfileVM()
            {
                User = user
            };

            return(View(vm));
        }
        //поиск закладок
        public async Task <ActionResult> LinksSearch(string filter, int?page)
        {
            ProfileVM profileVM = new ProfileVM();

            int pageNumber = page ?? 1;

            using (var profile = new ChekitDB())
            {
                var modelDTO = new ProfileDTO()
                {
                    AllLinks = await profile.Links.ToListAsync()
                };

                var modelVM = new ProfileVM()
                {
                    AllUserLinks = modelDTO.AllLinks.OrderBy(x => x.LinkName).Select(x => new LinkVM(x)).ToList()
                };

                profileVM.AllUserLinks = modelVM.AllUserLinks.Where(x => x.SearchLink().ToLower().Contains(filter.ToLower())).ToList();

                var linksOnPage = modelVM.AllUserLinks.ToPagedList(pageNumber, 50);
                ViewBag.linksOnPage = linksOnPage;

                return(PartialView("_AllLinksPartial", profileVM));
            }
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> SaveChanges(ProfileVM settings)
        {
            AppUser user = await _userManager.FindByNameAsync(User.Identity.Name);

            if (user == null)
            {
                return(NotFound());
            }
            UserDetail userD = _db.UserDetails.FirstOrDefault(u => u.AppUserId == user.Id);

            ViewBag.Age   = "";
            user.FullName = settings.AppUser.FullName;
            if (settings.UserDetail.Birthday != null && settings.UserDetail.Birthday.Year != 1)
            {
                userD.Birthday = settings.UserDetail.Birthday;
            }
            string gender = Request.Form["Gender"];

            userD.Gender = gender;
            if (settings.UserDetail.PhoneNumber != null)
            {
                userD.PhoneNumber = settings.UserDetail.PhoneNumber;
            }
            userD.InstagramLink = settings.UserDetail.InstagramLink;
            userD.FacebookLink  = settings.UserDetail.FacebookLink;

            await _db.SaveChangesAsync();

            return(RedirectToAction(User.Identity.Name, "profil"));
        }
        //список заблокированных юзеров
        public async Task <ActionResult> BlackList(int?page)
        {
            ProfileVM profileVM = new ProfileVM();

            int pageNumber = page ?? 1;

            using (var profile = new ChekitDB())
            {
                var modelDTO = new ProfileDTO()
                {
                    ListBlackListUsersDTO = await profile.BlackList.ToListAsync(),
                    UsersListDTO          = await profile.Users.ToListAsync()
                };

                var modelVM = new ProfileVM()
                {
                    ListBlackListUsersVM = modelDTO.ListBlackListUsersDTO.ToArray().OrderBy(x => x.Id).Select(x => new BlackListVM(x)).ToList(),
                    UsersList            = modelDTO.UsersListDTO.Where(x => x.BanStatus == true).Select(x => new UserVM(x)).ToList()
                };

                var usersOnPage = modelVM.ListBlackListUsersVM.ToPagedList(pageNumber, 20);
                ViewBag.usersOnPage = usersOnPage;

                return(View(modelVM));
            }
        }