Пример #1
0
        public IActionResult Create(PostInputModel model)
        {
            if (this.ModelState.IsValid)
            {
                ForumUser user = this.accountService.GetUser(this.User);
                this.postService.AddPost(model, user, model.ForumId).GetAwaiter().GetResult();

                return(this.Redirect($"/Forum/Posts?Id={model.ForumId}"));
            }
            else
            {
                var result = this.View("Error", this.ModelState);
                result.StatusCode = (int)HttpStatusCode.BadRequest;

                return(result);
            }
        }
Пример #2
0
 public override async Task <Comment> AddAsync(Comment objectToAdd, Action additionalSteps = null)
 {
     return(await base.AddAsync(objectToAdd, async() =>
     {
         additionalSteps?.Invoke();
         objectToAdd.SetInitialValues();
         ForumUser author = await((ForumContext)context).Users.FindAsync(objectToAdd.Author.Id);
         if (author != null && author.IsConfirmed)
         {
             objectToAdd.Author = author;
         }
         else
         {
             throw new AuthorNotFoundException("Comment cannot be applied because user does not exist or is not confirmed");
         }
     }));
 }
        private void SeedUsers(out ForumUser user, out ForumUser secondUser)
        {
            user = new ForumUser {
                Id = TestsConstants.TestId, SecurityStamp = "test", UserName = TestsConstants.TestUsername1, RegisteredOn = DateTime.UtcNow.AddDays(1)
            };
            secondUser = new ForumUser {
                Id = TestsConstants.TestId2, SecurityStamp = "test", Email = TestsConstants.TestEmail, UserName = TestsConstants.TestUsername2, RegisteredOn = DateTime.UtcNow.AddDays(2)
            };
            var thirdUser = new ForumUser {
                Id = TestsConstants.TestId3, SecurityStamp = "test", UserName = TestsConstants.TestUsername3, RegisteredOn = DateTime.UtcNow.AddDays(3)
            };

            this.dbService.DbContext.Users.Add(user);
            this.dbService.DbContext.Users.Add(secondUser);
            this.dbService.DbContext.Users.Add(thirdUser);
            this.dbService.DbContext.SaveChanges();
        }
 public ActionResult ViewTopic(int id)
 {
     topic = ts.GetTopicByTopicID(id);
     user  = fum.GetUserByEmail(User.Identity.Name.ToString());
     if (user != null)
     {
         int userAccessFlag = GetUserAccessFlageByUserandForumID(user, topic.ForumId);
         ViewBag.isReplyable = am.isReplyable(userAccessFlag);
     }
     else
     {
         ViewBag.isReplyable = false;
     }
     ViewBag.Forum = fs.GetForumByID(topic.ForumId);
     ts.UpdateViewCount(id);
     return(View(topic));
 }
        public PartialViewResult RenderPost(int topicID, int page, int pageSize)
        {
            ViewBag.topicID = topicID;
            postList        = ps.GetPostListByTopicID(topicID);
            PagedList <Post> pagedPost = new PagedList <Post>(postList, page, pageSize);

            user = fum.GetCurrentForumUser(User.Identity.GetUserId());
            if (user != null)
            {
                ViewBag.currentUserID = user.Id;
            }
            else
            {
                ViewBag.currentUserID = 0;
            }
            return(PartialView("_Post", pagedPost));
        }
Пример #6
0
        public async Task <IActionResult> AddComment(int id, [Bind("CommentId,Text,DateCreated,DateModified,UserId,TopicId, UserName")] Comment commentModel)
        {
            var       userId          = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId
            var       userName        = User.FindFirstValue(ClaimTypes.Name);           // will give the user's userName
            ForumUser applicationUser = await _userManager.GetUserAsync(User);

            string userEmail = applicationUser?.Email; // will give the user's Email

            if (ModelState.IsValid)
            {
                //Insert
                if (id == 0)
                {
                    commentModel.DateCreated = DateTime.Now;
                    commentModel.UserId      = userId;
                    commentModel.UserName    = userName;
                    //commentModel.TopicId = topicId;
                    _commentRepo.Insert(commentModel);
                    await _commentRepo.SaveAsync();
                }
                //Update
                else
                {
                    try
                    {
                        _commentRepo.Update(commentModel);
                        await _commentRepo.SaveAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (CommentModelExists(id) == null)
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                //var res = _topicRepo.GetByIdAsync(id);
                return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _commentRepo.GetAllAsync()) }));
            }
            return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddComment", commentModel) }));
        }
Пример #7
0
    protected void btnSumbit_Click(object sender, EventArgs e)
    {
        if (tbxComment.Text == "")
        {
            lbloutput.Text = "The Comment field cannot be blank.";
            return;
        }
        else
        {
            lbloutput.Text = "";

            if (Session["hyper1"].ToString() == "1")
            {
                ForumUser             fu  = ForumUserDB.getForumUserbyID(Session["hyper"].ToString());
                Establishment         es  = (Establishment)Session["establishment"];
                ForumUserCommentbyEst fue = new ForumUserCommentbyEst(fu, tbxComment.Text, es, System.DateTime.Now, "allow");
                int num = ForumUserCommentbyEstDB.insertForumCommentUser(fue);
                if (num != 1)
                {
                    lbloutput.Text = "Fail to comment!";
                    return;
                }
                else
                {
                    Response.Redirect("ForumCommentE.aspx", true);
                }
            }
            else
            {
                ForumEstablishment   fe  = ForumEstablishmentDB.getForumEstbyID(Session["hyper1"].ToString());
                Establishment        es  = (Establishment)Session["establishment"];
                ForumEstCommentbyEst fee = new ForumEstCommentbyEst(fe, tbxComment.Text, es, System.DateTime.Now, "allow");
                int num = ForumEstCommentbyEstDB.insertForumCommentEst(fee);
                if (num != 1)
                {
                    lbloutput.Text = "Fail to comment!";
                    return;
                }
                else
                {
                    Response.Redirect("ForumCommentE.aspx", true);
                }
            }
        }
    }
Пример #8
0
        public int Save(ForumUser user)
        {
            int userId;

            SharePointListProvider provider = new SharePointListProvider(ForumApplication.Instance.SpWeb);
            SharePointListItem     listItem = UserMapper.CreateDto(user);

            if (user.Id == 0)
            {
                userId = provider.AddListItem(ForumConstants.Lists_Users, listItem);
            }
            else
            {
                userId = provider.UpdateListItem(ForumConstants.Lists_Users, listItem);
            }

            return(userId);
        }
        public ActionResult ViewForum(int id)
        {
            user = fum.GetUserByEmail(User.Identity.Name.ToString());
            if (user != null)
            {
                int userAccessFlag = GetUserAccessFlageByUserandForumID(user, id);
                ViewBag.isPostable = am.isPostable(userAccessFlag);
            }
            else
            {
                ViewBag.isPostable = false;
            }

            forum = fs.GetForumByID(id);
            ViewBag.categoryName = cs.GetCategoryByID(forum.CategoryId).Name;

            return(View(forum));
        }
        public ActionResult SignUp(UserSignUpModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var users = new ForumUser();
                    var data  = new byte[model.File.ContentLength];
                    model.File.InputStream.Read(data, 0, model.File.ContentLength);
                    model.Image     = data;
                    users.Image     = model.Image;
                    users.FirstName = model.FirstName;
                    users.LastName  = model.LastName;
                    users.UserName  = model.UserName;
                    users.Country   = model.Country;
                    users.Email     = model.Email;
                    users.Password  = model.Password;
                    _db.ForumUser.Add(users);
                    _db.SaveChanges();
                    var pi = new PostInformation();

                    var u = _db.ForumUser.SingleOrDefault(m => m.UserName.Equals(model.UserName));
                    if (u != null)
                    {
                        pi.UserId = u.UserId;
                    }
                    pi.TotalAnsPost     = 0;
                    pi.TotalCommentPost = 0;
                    pi.TotalQuesPost    = 0;
                    pi.TotalValidPost   = 0;
                    _db.PostInformation.Add(pi);
                    _db.SaveChanges();
                    return(RedirectToAction("Login", "Account"));
                }
            }
            catch (Exception)
            {
                Response.Write("<div id='logDialog'>");
                Response.Write("You must upload your Image.And Image must be of jpg typed");
                Response.Write("</div>");
                return(View(model));
            }
            return(View());
        }
Пример #11
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            string userName = UserName.Text;
            var manager = new AuthenticationIdentityManager(new IdentityStore(new ForumEmeraldContext()));
            string filename = string.Empty;

            ForumUser user = new ForumUser()
            {
                UserName = userName,
                Email = this.TextBoxEmail.Text,
            };

            var fileUpload = this.FileUploadPhoto;
            if (fileUpload.HasFile && (fileUpload.PostedFile.ContentType == PngImageFormat ||
                    FileUploadPhoto.PostedFile.ContentType == JpegImageFormat))
            {
                filename = userName + GetPhotoExtension(FileUploadPhoto.PostedFile.FileName);
                fileUpload.SaveAs(Server.MapPath(MainPath) + filename);
                user.PhotoPath = MainPath + filename;
            }
            else
            {
                user.PhotoPath = DefaultImagePath;
            }

            IdentityResult result = manager.Users.CreateLocalUser(user, Password.Text);

            if (result.Success)
            {
                manager.Authentication.SignIn(Context.GetOwinContext().Authentication, user.Id, isPersistent: false);
                this.AddUserToRole();
                OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                if (this.FileUploadPhoto.HasFile)
                {
                    File.Delete(this.Server.MapPath(MainPath + filename));
                }

                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
Пример #12
0
        public ActionResult Index()
        {
            if (!this.categoryService.FindAll().Any())
            {
                ForumUser user = this.forumUserService.Create("testuser", "*****@*****.**", "Mister Test User", "todo", "da-DK", "uhm");

                Category firstCategory  = this.categoryService.Create("First Category", 1, "");
                Category secondCategory = this.categoryService.Create("Second Category", 2, "");

                Forum forum1 = this.forumService.Create(firstCategory.Id, "first forum", 1, "meh");
                Forum forum2 = this.forumService.CreateSubForum(forum1.Id, "first, first forum", 1, "boh");
                Forum forum3 = this.forumService.Create(firstCategory.Id, "first forum", 2, "meh");

                Topic topic1 = this.topicService.Create(forum2.Id, "first topic", "bla bla bla");
                Topic topic2 = this.topicService.Create(forum2.Id, "second topic", "bla bla bla");
            }

            return(View(this.uiService.FindCategoriesPlus2Levels()));
        }
Пример #13
0
        /// <summary>
        /// Adds a thread to the users subscriptions
        /// </summary>
        /// <param name="threadId"></param>
        /// <returns></returns>
        public async Task AddThreadToSubscriptionsAsync(int threadId)
        {
            using (DatabaseContext context = new DatabaseContext())
            {
                // Get the user
                ForumUser user = await context.ForumUsers.FindAsync(HttpContext.Current.User.Identity.GetUserId());

                Thread thread = await context.Threads.FindAsync(threadId);

                // Adding the thread to the subscriptions of the person
                user.Subscriptions.Add(thread);

                // Adding the user  to the subscriptions of the thread
                thread.Subscribers.Add(user);

                // Saving everything to the database
                await context.SaveChangesAsync();
            }
        }
        public ActionResult Update(ForumUser model, string submitFlag, int userGroup)
        {
            if (submitFlag.Equals(SubmitFlagUtilities.UpdateUser.ToString()))
            {
                //If Update User
                if (this.UpdateUser(model))
                {
                    TempData["SuccessUpdateUser"] = "******";
                }
                else
                {
                    TempData["FailToUpdateUser"] = "******";
                }

                return(RedirectToAction("Update", model.Id));
            }
            if (submitFlag.Equals(SubmitFlagUtilities.UpdateUserRole.ToString()))
            {
                //If Update User Role
            }
            if (submitFlag.Equals(SubmitFlagUtilities.AddUserGroup.ToString()))
            {
                //If Update User Group
                if (userGroup == 0)
                {
                    TempData["FailToAddGroup"] = "Please select proper value!";
                }
                else
                {
                    if (AddUserGroup(model, userGroup))
                    {
                        TempData["SuccessAddGroup"] = "Add Success!";
                    }
                    else
                    {
                        TempData["FailToAddGroup"] = "Add Failed!";
                    }
                }
                return(RedirectToAction("Update", model.Id));
            }
            return(View());
        }
        public async Task <Topic> AddTopic(Topic topic, int forumID, ForumUser user)
        {
            this.topic.Title            = topic.Title;
            this.topic.ViewCount        = 1;
            this.topic.PostCount        = 1;
            this.topic.Flag             = 0;
            this.topic.Type             = topic.Type;
            this.topic.LastPosted       = DateTime.Now.ToString();
            this.topic.ForumId          = forumID;
            this.topic.AuthorId         = user.Id;
            this.topic.AuthorName       = user.FirstName;
            this.topic.LastPostAuthorId = user.Id;
            this.topic.LastPostUsername = user.FirstName;
            this.topic.SpamScore        = 0;
            this.topic.SpamReporters    = 0;
            this.topic.Posted           = DateTime.Now.ToString();
            context.Topic.Add(this.topic);
            await context.SaveChangesAsync();

            return(GetTopicByPostDate(this.topic.Posted));
        }
        public bool UpdateUser(ForumUser model)
        {
            ForumUserManager fum = new ForumUserManager();

            ApplicationUser user = this.UserManager.FindById(model.ProviderId);

            user.FirstName = model.FirstName;
            user.LastName  = model.LastName;

            var result = UserManager.Update(user);

            if (result.Succeeded)
            {
                fum.UpdateUser(model);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #17
0
        public ActionResult Register(ForumUser x) // skapar en användare genom den mottagna parametern med validation
        {
            var dump = db.ForumUsers.FirstOrDefault(b => b.Username == x.Username);

            if (dump != null)
            {
                ModelState.AddModelError("", "Invalid username, it is already taken.");
                return(View());
            }

            if (dump == null)
            {
                db.ForumUsers.Add(x);
                db.SaveChanges();
                return(RedirectToAction("AccountCreated"));
            }
            else
            {
                ModelState.AddModelError("", "Failed to create an account.");
                return(View());
            }
        }
Пример #18
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ForumUser user = new ForumUser();

            user.FirstName = txtFName.Text;
            user.LastName  = txtFName.Text;
            user.Username  = txtUsername.Text;
            if (Convert.ToInt32(Session["pwd"]) == 0)
            {
                user.Password = txtPassword.Text.GetHashCode().GetHashCode();
            }
            else
            {
                user.Password = Convert.ToInt32(Session["pwd"]);
            }
            user.Role        = "Registered User";
            user.DateOfBirth = Calendar1.SelectedDate;
            user.Email       = txtEmail.Text;
            user.FacebookId  = txtFacebook.Text;
            user.TwitterId   = txtTwitter.Text;
            user.CreateUserinDb();
        }
Пример #19
0
        private void SeedDb()
        {
            this.TruncateForumsTable();
            this.TruncatePostsTable();
            this.TruncateUsersTable();
            this.TruncateRepliesTable();

            var user = new ForumUser {
                Id = TestsConstants.TestId, UserName = TestsConstants.TestUsername1
            };

            this.dbService.DbContext.Users.Add(user);
            this.dbService.DbContext.SaveChanges();

            var post = new Models.Post {
                Author = user, Description = TestsConstants.ValidPostDescription, AuthorId = user.Id, Id = TestsConstants.TestId3
            };

            this.dbService.DbContext.Posts.Add(post);
            this.dbService.DbContext.SaveChanges();

            var firstReply = new Models.Reply {
                Id = TestsConstants.TestId, Author = user, AuthorId = user.Id, Post = post, PostId = post.Id
            };

            this.dbService.DbContext.Replies.Add(firstReply);
            this.dbService.DbContext.SaveChanges();

            for (int i = 0; i < 5; i++)
            {
                var reply = new Models.Reply {
                    Id = Guid.NewGuid().ToString(), Author = user, AuthorId = user.Id, Post = post, PostId = post.Id
                };

                this.dbService.DbContext.Replies.Add(reply);
                this.dbService.DbContext.SaveChanges();
            }
        }
Пример #20
0
        public async Task <ActionResult> UserProfile(string username)
        {
            // Get the user
            ForumUser forumUser = await ForumUserManager.FindByUserNameAsync(username);

            User user = forumUser.User;

            // Populate the model
            UserProfileViewModel model = new UserProfileViewModel()
            {
                UserName     = user.UserName,
                Reputation   = forumUser.Reputation,
                Postcount    = forumUser.PostsCount,
                Role         = user.PrimaryRole,
                LastActivity = forumUser.LastActivity,
                JoinDate     = forumUser.JoinDate,
                Country      = user.Country,
                Seniorty     = user.Seniority,
                Image        = ProfilePictureSystem.GetProfilePicture(user.Id),
            };

            return(View(model));
        }
Пример #21
0
        public async Task UpdateAvatar(ForumUser user)
        {
            if (user.Avatar == null)
            {
                var  fileName       = user.UserName + Path.GetExtension(Input.Photo.FileName);
                bool setPhotoResult = await _imageRepo.Create(Input.Photo, "avatars", fileName);
            }
            else
            {
                fileName       = user.Avatar;
                setPhotoResult = await _imageRepo.Update(Input.Photo, "avatars", fileName);
            }

            if (!setPhotoResult)
            {
                throw new InvalidOperationException(_imageRepo.ResponseError);
            }
            else
            {
                user.Avatar = fileName;
                await _userManager.UpdateAsync(user);
            }
        }
Пример #22
0
        public async Task <JsonResult> AddComment([FromBody] Comment comment)
        {
            var userId   = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId
            var userName = User.FindFirstValue(ClaimTypes.Name);           // will give the user's userName

            ForumUser applicationUser = await _userManager.GetUserAsync(User);

            string userEmail = applicationUser?.Email; // will give the user's Email

            comment.DateCreated  = DateTime.Now;
            comment.DateModified = DateTime.Now;
            comment.TopicId      = 2;

            if (ModelState.IsValid)
            {
                _commentRepo.Insert(comment);
                _commentRepo.Save();
                return(Json("succes"));
            }


            return(Json("error"));
        }
        public ActionResult Update(int id)
        {
            ForumUserManager   fum  = new ForumUserManager();
            GroupMemberService gms  = new GroupMemberService();
            ForumUser          user = fum.GetForumUser(id);
            //Add drop down list
            Dictionary <int, string> userGroupList = new UserGroupNameCollection().GetGroupNameDicList();
            List <SelectListItem>    dropDownList  = new List <SelectListItem>();

            dropDownList.Add(new SelectListItem {
                Text = "-- Select One--", Value = "0"
            });
            foreach (KeyValuePair <int, string> group in userGroupList)
            {
                dropDownList.Add(new SelectListItem {
                    Text = group.Value, Value = group.Key.ToString()
                });
            }

            ViewBag.UserGroupList = gms.GetUserGroup(id);
            ViewBag.groupList     = dropDownList;
            return(View(user));
        }
Пример #24
0
        /// <summary>
        /// Creates a new forum user
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public ForumUser Create(User user)
        {
            ForumUser result = new ForumUser
            {
                UserId       = user.Id,
                UserName     = user.UserName,
                Reputation   = 0,
                PostsCount   = 0,
                Signature    = "",
                JoinDate     = DateTime.Now,
                LastActivity = DateTime.Now
            };

            using (DatabaseContext context = new DatabaseContext())
            {
                context.Users.Attach(user);
                context.ForumUsers.Add(result);
                result.User = user;
                context.SaveChanges();
            }

            return(result);
        }
Пример #25
0
        /// <summary>
        /// Creates a new forum user
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <ForumUser> CreateAsync(string userId)
        {
            // Get the user
            User user = await Context.Users.SingleAsync(u => u.Id == userId);

            ForumUser result = new ForumUser
            {
                UserId       = user.Id,
                UserName     = user.UserName,
                Reputation   = 0,
                PostsCount   = 0,
                Signature    = "",
                JoinDate     = DateTime.Now,
                LastActivity = DateTime.Now,
                User         = user
            };

            Context.ForumUsers.Add(result);
            await Context.SaveChangesAsync();


            return(result);
        }
        public async System.Threading.Tasks.Task <ActionResult> Create(Post post, string message, int mainPostID)
        {
            StringBuilder sbBody = new StringBuilder();

            sbBody.Append(HttpUtility.HtmlEncode(message));

            message = sbBody.ToString();
            message = message.Replace(Environment.NewLine, "<br />");

            Post   mainPost = ps.GetPostByID(mainPostID);
            string ip       = Request.UserHostAddress;

            user      = fum.GetCurrentForumUser(User.Identity.GetUserId());
            this.post = await ps.AddPost(post.Subject, message, ip, mainPost.TopicId, user);

            if (this.post != null)
            {
                await fs.UpdateForumCountByForumID(mainPost.Topic.ForumId, mainPost.TopicId, post.Id, user, ForumCountUtilities.POST);

                ts.UpdateLastPostUsernameandDateByLastPost(this.post.TopicId, user.FirstName, DateTime.Now.ToString());
                return(RedirectToAction("ViewTopic", "Topic", new { id = mainPost.TopicId }));
            }
            return(View());
        }
        public async Task SeedAsync(ForumDbContext dbContext, IServiceProvider serviceProvider)
        {
            var userManager = serviceProvider.GetService <UserManager <ForumUser> >();

            var isExisting = await userManager.Users.AnyAsync(u => u.UserName == GlobalConstants.TestUserUserName);

            if (!isExisting)
            {
                var testUser = new ForumUser
                {
                    UserName       = GlobalConstants.TestUserUserName,
                    Email          = GlobalConstants.TestUserEmail,
                    ProfilePicture = GlobalConstants.TestUserProfilePicture,
                    EmailConfirmed = true
                };

                var result = await userManager.CreateAsync(testUser, GlobalConstants.TestUserPassword);

                if (!result.Succeeded)
                {
                    throw new Exception(string.Join(Environment.NewLine, result.Errors.Select(e => e.Description)));
                }
            }
        }
Пример #28
0
        public Boolean CreateAccount(String accountName, String password, String emailAddress, out String errorMessage)
        {
            IEventPublisher eventPublisher = DependencyResolver.Current.GetService<IEventPublisher>();
            NewUserEvent e = new NewUserEvent { Username = accountName, EmailAddress = emailAddress, IPAddress = HttpContext.Current.Request.UserHostAddress };
            eventPublisher.Publish(e);
            // If any of the anti-bot event handlers are running synchronously, we better check!
            if (e.Bot) {
                errorMessage = "User was rejected";
                return false;
            }

            IdentityResult result = this.userManager.Create(new ApplicationUser {
                UserName = accountName,
                Email = emailAddress,
                AccessFailedCount = 0,
                LockoutEnabled = true,
                LastActivityDate = DateTime.UtcNow,
                Approved = true,
                CreationDate = DateTime.UtcNow,
                LastLockoutDate = DateTime.UtcNow,
                LastLoginDate = new DateTime(1970, 1, 1)
            }, password);
            errorMessage = String.Empty;
            if (!result.Succeeded) {
                errorMessage = String.Join(",", result.Errors);
            }
            else {
                ApplicationUser user = this.userManager.FindByName(accountName);

                IConfiguration config = DependencyResolver.Current.GetService<IConfiguration>();
                ForumUser u = new ForumUser(user.Id, user.UserName, user.Email, HttpContext.Current.Request.UserHostAddress);
                u.Timezone = config.DefaultTimezone;
                u.Culture = config.DefaultCulture;
                context.ForumUsers.Add(u);
                context.SaveChanges();

                foreach (Int32 groupId in config.NewUserGroups) {
                    if (groupId > 0) {
                        Group group = this.context.Groups.Find(groupId);
                        this.context.GroupMembers.Add(new GroupMember(group, u));
                    }
                }

                context.SaveChanges();
            }

            return result.Succeeded;
        }
Пример #29
0
 public int Save(ForumUser user)
 {
     return(_dao.Save(user));
 }
Пример #30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Establishment)Session["establishment"] == null)
        {
            Server.Transfer("Login.aspx");
        }
        else
        {
            if (Session["hyper"].ToString() == "1")
            {
                if (Session["hyper1"].ToString() == "1")
                {
                    Server.Transfer("EstForum.aspx");
                }
                else
                {
                    lblNotFound.Visible = false;
                    ForumEstablishment fe = ForumEstablishmentDB.getForumEstbyID(Session["hyper1"].ToString());
                    lblheading.Text = "ForumID: #" + fe.forumID;
                    List <ForumEstablishment> felist = new List <ForumEstablishment>();
                    felist.Add(fe);

                    lbltitle.Text   = fe.Title;
                    lblmessage.Text = fe.message;
                    lblUser.Text    = fe.estID.ID;
                    lblDate.Text    = string.Format("{0:dd/MM/yyyy}", fe.date);

                    List <ForumEstCommentbyUser> fecu = ForumEstCommentbyUserDB.getoneForumAllCommentbyID(fe.forumID);
                    List <ForumEstCommentbyEst>  fece = ForumEstCommentbyEstDB.getoneForumAllCommentbyID(fe.forumID);

                    foreach (ForumEstCommentbyUser f in fecu)
                    {
                        tempcomment tc = new tempcomment();
                        tc.comment   = f.comments;
                        tc.commentby = f.commentby.Name.ToString();
                        tc.time      = f.date;
                        tc.timeshow  = datesub(f.date);
                        if (f.status == "allow")
                        {
                            tclist.Add(tc);
                        }
                    }

                    foreach (ForumEstCommentbyEst g in fece)
                    {
                        tempcomment tc = new tempcomment();
                        tc.comment   = g.comments;
                        tc.commentby = g.commentby.Name.ToString();
                        tc.time      = g.date;
                        tc.timeshow  = datesub(g.date);
                        if (g.status == "allow")
                        {
                            tclist.Add(tc);
                        }
                    }

                    if (tclist.Count == 0)
                    {
                        lblNotFound.Visible = true;
                        lblNotFound.Text    = "There is no comment";
                        PanelCMT.Visible    = false;
                    }
                    else
                    {
                        tclist = tclist.OrderBy(x => x.time).ToList();
                        tclist.Reverse();
                        lblNotFound.Text     = "";
                        PanelCMT.Visible     = true;
                        GridView1.DataSource = tclist;
                        GridView1.DataBind();
                    }
                }
            }
            else
            {
                ForumUser fu = ForumUserDB.getForumUserbyID(Session["hyper"].ToString());
                lblheading.Text = "ForumID: #" + fu.forumID;
                List <ForumUser> flist = new List <ForumUser>();
                flist.Add(fu);

                lbltitle.Text   = fu.Title;
                lblmessage.Text = fu.message;
                lblUser.Text    = fu.userID.username;
                lblDate.Text    = string.Format("{0:dd/MM/yyyy}", fu.date);

                List <ForumUserCommentbyEst>  fuce = ForumUserCommentbyEstDB.getoneForumAllCommentbyID(fu.forumID);
                List <ForumUserCommentbyUser> fucu = ForumUserCommentbyUserDB.getoneForumAllCommentbyID(fu.forumID);

                foreach (ForumUserCommentbyEst f in fuce)
                {
                    tempcomment tc = new tempcomment();
                    tc.comment   = f.comments;
                    tc.commentby = f.commentby.Name.ToString();
                    tc.time      = f.date;
                    tc.timeshow  = datesub(f.date);
                    if (f.status == "allow")
                    {
                        tclist.Add(tc);
                    }
                }

                foreach (ForumUserCommentbyUser g in fucu)
                {
                    tempcomment tc = new tempcomment();
                    tc.comment   = g.comments;
                    tc.commentby = g.commentby.username.ToString();
                    tc.time      = g.date;
                    tc.timeshow  = datesub(g.date);
                    if (g.status == "allow")
                    {
                        tclist.Add(tc);
                    }
                }

                if (tclist.Count == 0)
                {
                    lblNotFound.Visible = true;
                    lblNotFound.Text    = "There is no comment";
                    PanelCMT.Visible    = false;
                }
                else
                {
                    tclist = tclist.OrderBy(x => x.time).ToList();
                    tclist.Reverse();
                    lblNotFound.Text     = "";
                    PanelCMT.Visible     = true;
                    GridView1.DataSource = tclist;
                    GridView1.DataBind();
                }
            }
        }
    }
Пример #31
0
        private bool ChangeUsername(ForumUser user, string username)
        {
            var result = this.userManager.SetUserNameAsync(user, username).GetAwaiter().GetResult();

            return(result.Succeeded);
        }
Пример #32
0
 public void ChangePassword(ForumUser user, string oldPassword, string newPassword)
 {
     var result = this.userManager.ChangePasswordAsync(user, oldPassword, newPassword).GetAwaiter().GetResult();
 }