Exemplo n.º 1
0
        public IActionResult Index(WelcomeModel model)
        {
            WelcomeModel user = null;

            using (var db = new WelcomeContext()) //использование контекста
            {
                user = db.welcomers.Where(x => x.name == model.name && x.profession == model.profession)
                       .FirstOrDefault();
            }

            if (user == null)
            {
                ViewBag.Message =
                    "Добро пожаловать! Вы автоматически зарегистрированы! Пожалуйста, перед тем, как выйти из здания подойдите к соответствующему окну!";

                using (var db = new WelcomeContext())
                {
                    db.Add(new WelcomeModel {
                        isinbuilding = true, lastin = DateTime.Now,
                        profession   = model.profession, name = model.name
                    });
                    db.SaveChanges();
                }
                return(View());
            }
            ViewBag.Message = "Добро пожаловать!";
            return(View());
        }
Exemplo n.º 2
0
        public IActionResult About(WelcomeModel model)
        {
            WelcomeModel user = null;

            using (var db = new WelcomeContext())
            {
                user         = db.welcomers.Where(x => x.name == model.name && x.profession == model.profession).FirstOrDefault();
                user.lastout = DateTime.Now;
            }
            AddDataInVisit(user);
            using (var db = new VisitContext())
            {
                db.Update(user);
            }
            return(View());
        }
Exemplo n.º 3
0
        public string WriteToDatabase([FromBody] Message m)
        {
            WelcomeContext wc       = null;
            string         response = string.Empty;

            try
            {
                DbContextOptionsBuilder <WelcomeContext> builder = new DbContextOptionsBuilder <WelcomeContext>();
                builder.UseInMemoryDatabase("Welcome");
                DbContextOptions <WelcomeContext> options = builder.Options;

                wc = new WelcomeContext(options);

                wc.WelcomeMessages.Add(
                    new Welcome {
                    WelcomeMessage = m.Content,
                    DateReceived   = DateTime.Now
                }
                    );

                wc.SaveChanges();

                response = wc.WelcomeMessages.OrderByDescending(i => i.Id)
                           .Select(f => f.WelcomeMessage)
                           .First().ToString();
            }
            catch (Exception ex)
            {
                response = ex.Message;
            }
            finally
            {
                wc.Dispose();
            }

            return(response);
        }
Exemplo n.º 4
0
 public AgentsController(IStringLocalizer <AgentsController> localizer, WelcomeContext context, UserAccessInfo UserInfo)
 {
     _localizer = localizer;
     _context   = context;
     _userinfo  = UserInfo;
 }
Exemplo n.º 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, WelcomeContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var locOptions = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >();

            app.UseRequestLocalization(locOptions.Value);

            app.UseSession();

            app.UseApplicationInsightsRequestTelemetry();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            DbInitializer.Initialize(context);
        }
Exemplo n.º 6
0
 public HotelReservationsController(IStringLocalizer <HotelReservationsController> localizer, WelcomeContext context, UserAccessInfo UserInfo)
 {
     _localizer = localizer;
     _context   = context;
     _userinfo  = UserInfo;
 }