Exemplo n.º 1
0
        private void favori_Click(object sender, RoutedEventArgs e)
        {
            UserTopic drv = (sender as MenuItem).DataContext as UserTopic;

            if (drv != null)
            {
                classes.General.WriteFavori("fav_topic.txt", classes.General.ReadFavori("fav_topic.txt") + drv.utForumID + "|" + drv.utID + "|" + drv.utTitle + "|" + drv.utLastReplyAuthor + "|" + drv.utAuthorAvatar + "#");
                MessageBox.Show("Favorilere başarıyla eklendi.");
            }
        }
Exemplo n.º 2
0
 public long CreateUserTopic(UserTopic ut)
 {
     DbParameter[] parms =
     {
         DbHelper.MakeInParam("@UID",       (DbType)SqlDbType.BigInt,     8, ut.UID),
         DbHelper.MakeInParam("@TopicID",   (DbType)SqlDbType.BigInt,     8, ut.TopicID),
         DbHelper.MakeInParam("@TopicName", (DbType)SqlDbType.NVarChar, 100, ut.TopicName)
     };
     return(TypeConverter.ObjectToLong(DbHelper.ExecuteScalar(CommandType.StoredProcedure, "CreateUserTopic", parms), -1));
 }
Exemplo n.º 3
0
 public ActionResult SelectTopics(SelectedTopicViewModel model)
 {
     foreach (var topic in model.SelectedTopics)
     {
         var userTopic = new UserTopic();
         userTopic.Id      = Guid.NewGuid().ToString();
         userTopic.UserId  = User.Identity.GetUserId();
         userTopic.TopicId = topic;
         _context.UserTopics.Add(userTopic);
     }
     _context.Complete();
     return(RedirectToAction("Index", "Home"));
 }
Exemplo n.º 4
0
        // TODO: Consider moving SetUserTopic to TopicService.
        private void SetUserTopic(Guid UserId, Guid TopicId, TopicStatus topicStatus)
        {
            if (UserId == this.Actor.UserId || this.Actor.Roles.Contains("Admin"))
            {
                var dbUserTopic = TopicService.GetUserTopics(UserId, TopicId).FirstOrDefault();

                if (dbUserTopic == null)
                {
                    var newUserTopic = new UserTopic(UserId, TopicId, topicStatus);
                    this.mainContext.UserTopics.Add(newUserTopic);
                }

                this.mainContext.SaveChanges();
            }
        }
Exemplo n.º 5
0
        public static async Task InitializeAsync(IServiceProvider services)
        {
            var context = services.GetService <ApplicationDbContext>();

            context.Database.EnsureCreated();

            // Create the Admin User:
            var configuration = services.GetService <IConfiguration>();
            var manager       = services.GetService <UserManager <ApplicationUser> >();

            var admin = new ApplicationUser
            {
                Email          = configuration["Users:Admin:Email"],
                UserName       = configuration["Users:Admin:UserName"],
                EmailConfirmed = true,
            };

            await manager.CreateAsync(admin, configuration["Users:Admin:Password"]);

            // Add Topics:
            var topic1 = new Topic {
                Name = "Topic1"
            };
            var topic2 = new Topic {
                Name = "Topic2"
            };

            await context.DbSet <Topic>().AddRangeAsync(topic1, topic2);

            // Add UserTopics:
            var adminTopic1 = new UserTopic {
                User = admin, Topic = topic1, SubscriptionDate = DateTime.UtcNow
            };
            var adminTopic2 = new UserTopic {
                User = admin, Topic = topic2, SubscriptionDate = DateTime.UtcNow
            };

            await context.DbSet <UserTopic>().AddRangeAsync(adminTopic1, adminTopic2);

            // Add Firebase UserRegistration:
            var adminDevice1 = new UserRegistration {
                User = admin, RegistrationToken = "Your_Registration_Token"
            };

            await context.DbSet <UserRegistration>().AddRangeAsync(adminDevice1);

            await context.SaveChangesAsync();
        }
Exemplo n.º 6
0
        private void recentList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UserTopic drv = (UserTopic)recentList.SelectedItem;

            if (drv != null)
            {
                if (App.Session_LoadSession("aRefresh") == "1")
                {
                    reLoad = 0;
                }

                NavigationService.Navigate(new Uri("/forum/ForumPost.xaml?sforum_id=" + drv.utForumID + "&topic_id=" + drv.utID, UriKind.Relative));
            }

            recentList.SelectedIndex = -1;
        }
Exemplo n.º 7
0
 public static long CreateUserTopic(UserTopic ut)
 {
     try
     {
         if (ut == null)
         {
             return(-1);
         }
         return(Data.Topics.CreateUserTopic(ut));
     }
     catch (Exception ex)
     {
         Logs.WriteErrorLog(ex);
         return(-1);
     }
 }
        public async Task <IActionResult> RegisterKnowledge([FromRoute] Guid id)
        {
            var user = await _userManager.GetUserAsync(User);

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

            var alreadyHasKnowledge = await _context.UserTopics.AnyAsync(userTopic => userTopic.TopicId == id && userTopic.UserId == user.Id);

            if (!alreadyHasKnowledge)
            {
                var newUserTopic = new UserTopic {
                    TopicId = id, UserId = user.Id
                };
                _context.UserTopics.Add(newUserTopic);
                await _context.SaveChangesAsync();
            }

            return(Ok());
        }
Exemplo n.º 9
0
        //
        // GET: /Search/

        public ActionResult MiniBlog(SchMiniblogModel model)
        {
            if (model.Page == 0)
            {
                model.Page = 1;
            }
            if (!string.IsNullOrEmpty(model.timescope))
            {
                if (model.timescope == "1hour")
                {
                    model.StartTime = DateTime.Now.AddHours(-1);
                    model.EndTime   = DateTime.Now;
                }
                else if (model.timescope == "24hour")
                {
                    model.StartTime = DateTime.Now.AddHours(-24);
                    model.EndTime   = DateTime.Now;
                }
                else if (model.timescope == "1week")
                {
                    model.StartTime = DateTime.Now.AddDays(-7);
                    model.EndTime   = DateTime.Now;
                }
                else if (model.timescope == "15days")
                {
                    model.StartTime = DateTime.Now.AddDays(-15);
                    model.EndTime   = DateTime.Now;
                }
                else if (model.timescope == "1month")
                {
                    model.StartTime = DateTime.Now.AddMonths(-1);
                    model.EndTime   = DateTime.Now;
                }
                else if (model.timescope == "custom")
                {
                    if (model.StartTime == null)
                    {
                        model.StartTime = new DateTime(2000, 1, 1);
                    }
                    if (model.EndTime == null)
                    {
                        model.EndTime = DateTime.Now;
                    }
                }
            }
            model.CurUser       = CurrentUser;
            model.CurUserConfig = CurrentUserConfig;
            model.PageSize      = 20;
            int rowCount = 0;

            model.MiniBlogs       = MiniBlogs.SearchMiniBlog(model.Page, 20, ref rowCount, model.Key, model.IsOri, model.Location, model.StartTime, model.EndTime, model.IsMyself, model.IsMyFollow, CurrentUser.ID, model.SomeOne, model.IsHavePic, model.IsHaveLink, model.IsHaveVideo, model.IsHaveMusic, model.IsHaveVote, model.Sort, 0, 0);
            model.RecordCount     = rowCount;
            model.statisticTopics = Topics.GetTopStaticTopic(DateTime.Now.AddMonths(-1), DateTime.Now, 10);
            model.RelatedTopics   = Topics.GetTopicsBySearch(model.Key);
            ViewData["URL"]       = Request.Url.PathAndQuery;
            Topics.SaveTopic(model.Key);
            UserTopic ut = Topics.GetUserTopicByName(model.Key);

            if (ut != null)
            {
                model.CurUserTopicID = ut.ID;
            }
            else
            {
                model.CurUserTopicID = -1;
            }
            return(View(model));
        }
Exemplo n.º 10
0
 public static long CreateUserTopic(UserTopic ut)
 {
     return(DatabaseProvider.GetInstance().CreateUserTopic(ut));
 }