Ejemplo n.º 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSignalR(options =>
            {
                options.MaximumReceiveMessageSize = Int64.MaxValue;
            });

            var dbContextInitializer = new DBContextInitializer();

            _dbContext = dbContextInitializer.MakeDBContext(Configuration);
            services.AddSingleton <IDBContext>(_dbContext);

            var diagramService = new DiagramService(_dbContext);

            services.AddSingleton <IDiagramService>(diagramService);

            var actionService = new ActionService();

            services.AddSingleton <IActionService>(actionService);

            var mainNotifier = new MainNotifier();

            mainNotifier.Start();
            services.AddSingleton <IMainNotifier>(mainNotifier);

            services.AddControllers();
        }
        public ActionResult Index(tbl_Contact post)
        {
            if (ModelState.IsValid)
            {
                Stopwatch       sw        = Stopwatch.StartNew();
                ContactNotifier observer1 = new ContactNotifier();

                ActivityNotifier observer2 = new ActivityNotifier();

                post.date = DateTime.Now;


                db.tbl_Contact.Add(post);
                db.SaveChanges();



                TempData["SM"] = "You have added a new Record!";
                MainNotifier notifier = new MainNotifier();

                //ForumNotifier notifier = new ForumNotifier();


                notifier.Subscribe(observer1);

                notifier.Subscribe(observer2);

                notifier.Notify(post);

                sw.Stop();
                ViewBag.ExecutionTime = sw.Elapsed.Milliseconds;
                return(View("Index", post));
            }
            else
            {
                return(View("Index"));
            }
        }