Пример #1
0
        public ActionResult Details(string id)
        {
            List <string> list = new List <string>();

            foreach (var x in ReportContentViewModel.EnumToList <ReportContentViewModel.ReportUser>())
            {
                list.Add(ReportContentViewModel.GetEnumDescription(x));
            }
            ViewBag.reportContentList = list;
            var allUser = Context.Users.Find(_ => true).ToList();

            if (allUser.Where(x => x.Id.Equals(id)).Any() == false)
            {
                ViewBag.errorMessage = "Không có kết quả!";
                return(View("NotFoundError"));
            }
            else
            {
                var user = Context.Users.Find(x => x.Id.Equals(new ObjectId(id))).FirstOrDefault();
                ViewBag.currentUser      = User.Identity.GetUserId();
                ViewBag.cloudinary       = cloudinary;
                ViewBag.allUser          = allUser;
                ViewBag.allBook          = Context.Books.Find(_ => true).ToList();
                ViewBag.allAuthor        = Context.Authors.Find(_ => true).ToList();
                ViewBag.listInteractBook = BooksControllerHelper.LastestBookInteracted(id);
                return(View(user));
            }
        }
Пример #2
0
        //
        // GET: /UserProfile/Edit/5
        public ActionResult EditProfile(string id)
        {
            var allUser = Context.Users.Find(_ => true).ToList();

            if (allUser.Where(x => x.Id.Equals(id)).Any() == false)
            {
                ViewBag.errorMessage = "Không có kết quả!";
                return(View("NotFoundError"));
            }
            else
            {
                var         user       = Context.Users.Find(x => x.Id.Equals(new ObjectId(id))).FirstOrDefault();
                UserProfile newprofile = new UserProfile()
                {
                    id       = user.Id,
                    UserName = user.UserName,
                    DOB      = Convert.ToDateTime(user.DOB).ToString("dd/MM/yyyy"),
                    Gender   = user.Gender,
                    Address  = user.Address
                };
                ViewBag.cloudinary       = cloudinary;
                ViewBag.user             = user;
                ViewBag.currentUser      = User.Identity.GetUserId();
                ViewBag.allUser          = allUser;
                ViewBag.allAuthor        = Context.Authors.Find(_ => true).ToList();
                ViewBag.listInteractBook = BooksControllerHelper.LastestBookInteracted(id);
                return(View(newprofile));
            }
        }
Пример #3
0
        public async Task <ActionResult> EditProfile(UserProfile user1)
        {
            var allUser = Context.Users.Find(_ => true).ToList();

            if (user1.UserName != null)
            {
                foreach (var user in allUser)
                {
                    if (user.UserName.ToLower().Equals(user1.UserName.ToLower()) &&
                        allUser.Find(x => x.UserName.ToLower().Equals(user1.UserName.ToLower())).Id != user1.id)
                    {
                        ModelState.AddModelError("UserName", "Tên đã tồn tại");
                    }
                }
            }
            if (user1.DOB == null)
            {
                ModelState.AddModelError("DOB", "Ngày sinh không được để trống");
            }
            if (ModelState.IsValid)
            {
                var user2 = await UserManager.FindByIdAsync(user1.id);

                if (user2 == null)
                {
                    return(HttpNotFound());
                }

                user2.Address  = user1.Address;
                user2.DOB      = DateTime.ParseExact(user1.DOB, "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(7);
                user2.Gender   = user1.Gender;
                user2.UserName = user1.UserName;
                user2.Text     = CommonHelper.SearchString(user1.UserName.ToLower());
                await Context.Users.ReplaceOneAsync(x => x.Id.Equals(new ObjectId(user2.Id)), user2);

                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.cloudinary       = cloudinary;
            ViewBag.user             = Context.Users.Find(x => x.Id.Equals(new ObjectId(user1.id))).FirstOrDefault();
            ViewBag.currentUser      = User.Identity.GetUserId();
            ViewBag.allUser          = allUser;
            ViewBag.allAuthor        = Context.Authors.Find(_ => true).ToList();
            ViewBag.listInteractBook = BooksControllerHelper.LastestBookInteracted(user1.id);
            return(View(user1));
        }
Пример #4
0
 //
 // GET: /Groups/id/MainPage/
 public ActionResult MainPage(string id)
 {
     {
         var allGroup = Context.Groups.Find(_ => true).ToList();
         if (allGroup.Where(x => x.Id.Equals(id)).Any() == false)
         {
             ViewBag.errorMessage = "Không có kết quả!";
             return(View("NotFoundError"));
         }
         else
         {
             var group = Context.Groups.Find(x => x.Id.Equals(new ObjectId(id))).FirstOrDefault();
             if (group.Locked == true)
             {
                 return(RedirectToAction("LockedPage", "Home"));
             }
             else
             {
                 ViewBag.cloudinary = cloudinary;
                 var currentUser = User.Identity.GetUserId();
                 ViewBag.currentUser = currentUser;
                 var listGroupOfUser = new List <Group>();
                 foreach (var grp in allGroup)
                 {
                     if (grp.GroupMembers.Find(x => x.UserId.Equals(currentUser)) != null)
                     {
                         listGroupOfUser.Add(grp);
                     }
                 }
                 ViewBag.listGroupOfUser  = listGroupOfUser;
                 ViewBag.allUser          = Context.Users.Find(_ => true).ToList();
                 ViewBag.groupReport      = GroupReportContent();
                 ViewBag.allAuthor        = Context.Authors.Find(_ => true).ToList();
                 ViewBag.listInteractBook = BooksControllerHelper.LastestBookInteracted(User.Identity.GetUserId());
                 return(View(group));
             }
         }
     }
 }