Esempio n. 1
0
 /// <summary>
 /// Create a new inmemory db instance and fill it with test data
 /// </summary>
 /// <param name="initializer">initializer to be used for filling initial test data</param>
 /// <returns>In-memory db instance</returns>
 public AppDb CreateTransientDb(IInitializer initializer)
 {
     DbConnection con = Effort.DbConnectionFactory.CreateTransient();
     AppDb db = new AppDb(con);
     initializer.SeedData(db);
     return db;
 }
 /// <summary>
 /// Is called by ajax during the registration process
 /// </summary>
 /// <param name="email">email address to check agains the database</param>
 /// <returns>true if the email address is not in use by an other user</returns>
 public string EmailIsFree(string email)
 {
     string isFree = "false";
     using (AppDb db = new AppDb())
     {
         isFree = (db.Users.FirstOrDefault(u => u.Email.Equals(email)) == null?"true":"false");
     }
     return isFree;
 }
 public ActionResult Login(LoginCredentials login)
 {
     using(AppDb db = new AppDb()){
         UserAccount user = db.Users.FirstOrDefault(u => u.Email.Equals(login.Username));
         if (user != null)
         {
             if (user.Password.Equals(GenerateMD5(login.Password)))
             {
                 //user credentials are correct
                 FormsAuthentication.SetAuthCookie(user.Email, login.Remember);
                 return RedirectToAction("index", "game");
             }
         }
     }
     //login failed
     ViewData.ModelState.AddModelError("Username", "Der Benutzername oder das Passwort stimmt nicht!");
     ViewData.ModelState.AddModelError("Password", "Der Benutzername oder das Passwort stimmt nicht!");
     return View("~/Views/Home/Index.cshtml", login);
 }
Esempio n. 4
0
        public static void Run(int iterations, int concurrency, int ops)
        {
            var recordNum = 0;

            async Task InsertOne(AppDb db)
            {
                var blog = new BlogPost(db)
                {
                    Title   = "Title " + Interlocked.Increment(ref recordNum),
                    Content = "content"
                };
                await blog.InsertAsync();
            }

            var selected = new ConcurrentQueue <string>();

            async Task SelectTen(AppDb db)
            {
                var blogPosts = await(new BlogPostQuery(db)).LatestPostsAsync();

                selected.Enqueue(blogPosts.FirstOrDefault().Title);
            }

            var sleepNum = 0;

            async Task SleepMillisecond(AppDb db)
            {
                using (var cmd = db.Connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT SLEEP(0.001)";
                    await cmd.ExecuteNonQueryAsync();
                }
                Interlocked.Increment(ref sleepNum);
            }

            using (var db = new AppDb())
            {
                db.Connection.Open();
                using (var cmd = db.Connection.CreateCommand())
                {
                    cmd.CommandText = "DELETE FROM `BlogPost`";
                    cmd.ExecuteNonQuery();
                }
            }

            PerfTest(InsertOne, "Insert One", iterations, concurrency, ops).GetAwaiter().GetResult();
            using (var db = new AppDb())
            {
                db.Connection.Open();
                using (var cmd = db.Connection.CreateCommand())
                {
                    cmd.CommandText = "SELECT COUNT(*) FROM `BlogPost`";
                    Console.WriteLine("Records Inserted: " + cmd.ExecuteScalar());
                    Console.WriteLine();
                }
            }

            PerfTest(SelectTen, "Select Ten", iterations, concurrency, ops).GetAwaiter().GetResult();
            Console.WriteLine("Records Selected: " + selected.Count * 10);
            string firstRecord;

            if (selected.TryDequeue(out firstRecord))
            {
                Console.WriteLine("First Record: " + firstRecord);
            }
            Console.WriteLine();

            PerfTest(SleepMillisecond, "Sleep 1ms", iterations, concurrency, ops).GetAwaiter().GetResult();
            Console.WriteLine("Total Sleep Commands: " + sleepNum);
            Console.WriteLine();
        }
 public ProductsController(AppDb context)
 {
     _context = context;
 }
Esempio n. 6
0
 public BlogController(AppDb db)
 {
     Db = db;
 }
Esempio n. 7
0
 public RepositoryBase(AppDb repositoryContext)
 {
     this.RepositoryContext = repositoryContext;
 }
 public TechnologyQuery(AppDb db)
 {
     Db = db;
 }
Esempio n. 9
0
 public EditModel(AppDb db, IHtmlHelper htmlHelper)
 {
     _db         = db;
     _htmlHelper = htmlHelper;
 }
Esempio n. 10
0
 public Repository(AppDb db)
 {
     _db = db ?? throw new ArgumentNullException(nameof(db));
 }
 public AuthenticationHandler(AppDb db)
 {
     Db = db;
 }
 public TechnologyController(AppDb db)
 {
     Db = db;
 }
Esempio n. 13
0
        //int DataCount = 0;
        //List<Controlplan> DataStationDeviation = new List<Controlplan>();

        protected override bool OnInit(object sender, EventArgs e)
        {
            //get TableMeta from Schema. Schema is loaded during login
            var schemaInfo = Application["SchemaInfo"] as SchemaInfo;

            tableMeta = schemaInfo.Tables.Where(s => s.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            if (tableMeta == null)
            {
                masterPage.MainContent.Controls.Add(new LiteralControl(string.Format("<h2>{0}</h2>", "Invalid Page")));
                return(false);
            }


            //header info
            //int vpm = Request.QueryString["vpm"].ToInt32(0);
            //int modelId = Request.QueryString["model"].ToInt32(0);
            //int variantId = Request.QueryString["variant"].ToInt32(0);
            int cpId = Request.QueryString["CpId"].ToInt32(0);

            //int stationId = Request.QueryString["StationId"].ToInt32(0);
            //if (stationId == 0)
            //    stationId = Request.QueryString["station"].ToInt32(0);

            using (AppDb ctx = new AppDb())
            {
                if (cpId > 0)
                {
                    cp = ctx.ControlPlans.Where(x => x.Id == cpId).FirstOrDefault();
                }
                //else
                //{
                //    cp = ctx.ControlPlans.Where(x => x.ModelId == modelId && x.VariantId == variantId && x.PackingMonth == vpm.ToString()).FirstOrDefault();
                //}
            }

            if (cp == null)
            {
                var panel1 = new System.Web.UI.WebControls.Panel();
                panel1.CssClass = "mainContent";
                panel1.Controls.Clear();
                panel1.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>Invalid Model/Variant/PackingMonth for CP Station Detail</h2>")));

                masterPage.MainContent.Controls.Clear();
                masterPage.MainContent.Controls.Add(panel1);
                masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption));
                return(false);
            }
            //else if (stationId == 0)
            //{
            //    var panel1 = new System.Web.UI.WebControls.Panel();
            //    panel1.CssClass = "mainContent";
            //    panel1.Controls.Clear();
            //    panel1.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>Invalid Station for CP Station Detail</h2>")));

            //    masterPage.MainContent.Controls.Clear();
            //    masterPage.MainContent.Controls.Add(panel1);
            //    masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption));
            //    return false;
            //}

            //Set master key
            SetMasterKey("ControlPlanId", cp.Id);

            //Store the CP object so that it is accessible to other classes
            keyValues.Add("CP", cp);
            keyValues.Add("ControlPlanId", cp.Id);

            hfDocControl["PackingMonth"] = cp.PackingMonth;
            hfDocControl["ModelId"]      = cp.AssemblyModelId;

            //create header
            string ModelName = ControlPlanRepository.RetrieveAssemblyModelNameById(cp.AssemblyModelId);

            //string StationName = ControlPlanRepository.RetrieveStationNameById(stationId);

            //lblStationName.Text = StationName;
            lblPackingMonth.Text = cp.PackingMonth;
            lblModel.Text        = ModelName;

            //if (!IsPostBack && !IsCallback)
            //{
            //    if (Request.QueryString.Count > 0)
            //    {
            //        hfDocControl["ControlPlanId"] = cpId;
            //        if (cp != null)
            //        {
            //            hfDocControl["PackingMonth"] = cp.PackingMonth;
            //            hfDocControl["ModelId"] = cp.ModelId;
            //            hfDocControl["VariantId"] = cp.VariantId;

            //            lblPackingMonth.Text = cp.PackingMonth;
            //            lblModel.Text = ModelRepository.RetrieveModelNameById(cp.ModelId) + " " +
            //                            ModelRepository.RetrieveVariantNameByModelIdAndVariantId(
            //                                cp.ModelId, cp.VariantId);
            //        }
            //    }
            //}
            //else
            //{
            //    if (Session["StationId"] != null)
            //    {
            //        if (popupDocControl.HeaderText.ToString() == "Document Control - Working Instruction")
            //        {
            //            grvDocControlDetail.DataSourceID = null;
            //            grvDocControlDetail.DataSource = ControlPlanRepository.RetrieveDocumentByDocTypeAndStationId("CPWI",
            //            Convert.ToInt32(Session["StationId"].ToString()), cp.PackingMonth, Convert.ToInt32(cp.ModelId), Convert.ToInt32(cp.VariantId));
            //            grvDocControlDetail.DataBind();
            //        }
            //        else
            //        {
            //            grvDocControlDetail.DataSourceID = null;
            //            grvDocControlDetail.DataSource = ControlPlanRepository.RetrieveDocumentByDocTypeAndStationIdII("CPII",
            //            Convert.ToInt32(Session["StationId"].ToString()), cp.PackingMonth, Convert.ToInt32(cp.ModelId), Convert.ToInt32(cp.VariantId));
            //            grvDocControlDetail.DataBind();
            //        }

            //    }
            //}

            return(true);
        }
Esempio n. 14
0
        public async Task TestDataTypesVariable()
        {
            var emptyByteArray  = new byte[0];
            var emptyJsonArray  = new JsonObject <List <string> >(new List <string>());
            var emptyJsonObject = new JsonObject <Dictionary <string, string> >(new Dictionary <string, string>());

            // non-null data types must be initialized
            Func <DataTypesVariable> newEmptyMem = () => new DataTypesVariable
            {
                TypeString       = "",
                TypeString255    = "",
                TypeByteArray    = emptyByteArray,
                TypeByteArray255 = emptyByteArray,
                TypeJsonArray    = emptyJsonArray,
                TypeJsonObject   = emptyJsonObject,
            };

            Action <DataTypesVariable> testEmpty = valueDb =>
            {
                // string not null
                Assert.Equal("", valueDb.TypeString);
                Assert.Equal("", valueDb.TypeString255);
                // string null
                Assert.Equal(null, valueDb.TypeStringN);
                Assert.Equal(null, valueDb.TypeString255N);

                // binary not null
                Assert.Equal(emptyByteArray, valueDb.TypeByteArray);
                Assert.Equal(emptyByteArray, valueDb.TypeByteArray255);
                // binary null
                Assert.Equal(null, valueDb.TypeByteArrayN);
                Assert.Equal(null, valueDb.TypeByteArray255N);

                // json not null
                Assert.Equal(emptyJsonArray.Json, valueDb.TypeJsonArray.Json);
                Assert.Equal(emptyJsonObject.Json, valueDb.TypeJsonObject.Json);
                // json null
                Assert.Equal(null, valueDb.TypeJsonArrayN);
                Assert.Equal(null, valueDb.TypeJsonObjectN);
            };

            var string255 = new string('a', 255);
            var string10K = new string('a', 10000);

            var byte255 = new byte[255];
            var byte10K = new byte[10000];

            for (var i = 0; i < byte10K.Length; i++)
            {
                if (i < 255)
                {
                    byte255[i] = (byte)'a';
                }
                byte10K[i] = (byte)'a';
            }

            var jsonArray = new JsonObject <List <string> >(new List <string> {
                "test"
            });
            var jsonObject = new JsonObject <Dictionary <string, string> >(new Dictionary <string, string> {
                { "test", "test" }
            });

            // test each data type with a valid value
            Func <DataTypesVariable> newValueMem = () => new DataTypesVariable {
                // string not null
                TypeString    = string10K,
                TypeString255 = string255,  // should be truncated by DBMS
                // string null
                TypeStringN    = string10K,
                TypeString255N = string255, // should be truncated by DBMS

                // binary not null
                TypeByteArray    = byte10K,
                TypeByteArray255 = byte255,  // should be truncated by DBMS
                // binary null
                TypeByteArrayN    = byte10K,
                TypeByteArray255N = byte255, // should be truncated by DBMS

                // json not null
                TypeJsonArray  = jsonArray,
                TypeJsonObject = jsonObject,
                // json null
                TypeJsonArrayN  = jsonArray,
                TypeJsonObjectN = jsonObject,
            };

            Action <DataTypesVariable> testValue = valueDb =>
            {
                // string not null
                Assert.Equal(string10K, valueDb.TypeString);
                Assert.Equal(string255, valueDb.TypeString255);
                // string null
                Assert.Equal(string10K, valueDb.TypeStringN);
                Assert.Equal(string255, valueDb.TypeString255N);

                // binary not null
                Assert.Equal(byte10K, valueDb.TypeByteArray);
                Assert.Equal(byte255, valueDb.TypeByteArray255);
                // binary null
                Assert.Equal(byte10K, valueDb.TypeByteArrayN);
                Assert.Equal(byte255, valueDb.TypeByteArray255N);

                // json not null
                Assert.Equal(jsonArray.Json, valueDb.TypeJsonArray.Json);
                Assert.Equal(jsonObject.Json, valueDb.TypeJsonObject.Json);
                // json null
                Assert.Equal(jsonArray.Json, valueDb.TypeJsonArrayN.Json);
                Assert.Equal(jsonObject.Json, valueDb.TypeJsonObjectN.Json);
            };

            // create test data objects
            var emptyMemAsync = newEmptyMem();
            var emptyMemSync  = newEmptyMem();
            var valueMemAsync = newValueMem();
            var valueMemSync  = newValueMem();

            // save them to the database
            using (var db = new AppDb()){
                db.DataTypesVariable.Add(emptyMemAsync);
                db.DataTypesVariable.Add(valueMemAsync);
                await db.SaveChangesAsync();

                db.DataTypesVariable.Add(emptyMemSync);
                db.DataTypesVariable.Add(valueMemSync);
                db.SaveChanges();
            }

            // load them from the database and run tests
            using (var db = new AppDb())
            {
                // ReSharper disable once AccessToDisposedClosure
                Func <DataTypesVariable, Task <DataTypesVariable> > fromDbAsync =
                    async dt => await db.DataTypesVariable.FirstOrDefaultAsync(m => m.Id == dt.Id);

                // ReSharper disable once AccessToDisposedClosure
                Func <DataTypesVariable, DataTypesVariable> fromDbSync =
                    dt => db.DataTypesVariable.FirstOrDefault(m => m.Id == dt.Id);

                testEmpty(await fromDbAsync(emptyMemAsync));
                testEmpty(fromDbSync(emptyMemSync));
                testValue(await fromDbAsync(valueMemAsync));
                testValue(fromDbSync(valueMemSync));
            }
        }
Esempio n. 15
0
        public async Task TestDataTypesSimple()
        {
            Action <DataTypesSimple> testEmpty = emptyDb =>
            {
                // integers
                Assert.Equal(default(short), emptyDb.TypeShort);
                Assert.Equal(default(ushort), emptyDb.TypeUshort);
                Assert.Equal(default(int), emptyDb.TypeInt);
                Assert.Equal(default(uint), emptyDb.TypeUint);
                Assert.Equal(default(long), emptyDb.TypeLong);
                Assert.Equal(default(ulong), emptyDb.TypeUlong);
                // nullable integers
                Assert.Equal(null, emptyDb.TypeShortN);
                Assert.Equal(null, emptyDb.TypeUshortN);
                Assert.Equal(null, emptyDb.TypeIntN);
                Assert.Equal(null, emptyDb.TypeUintN);
                Assert.Equal(null, emptyDb.TypeLongN);
                Assert.Equal(null, emptyDb.TypeUlongN);

                // decimals
                Assert.Equal(default(decimal), emptyDb.TypeDecimal);
                Assert.Equal(default(double), emptyDb.TypeDouble);
                Assert.Equal(default(float), emptyDb.TypeFloat);
                // nullable decimals
                Assert.Equal(null, emptyDb.TypeDecimalN);
                Assert.Equal(null, emptyDb.TypeDoubleN);
                Assert.Equal(null, emptyDb.TypeFloatN);

                // byte
                Assert.Equal(default(sbyte), emptyDb.TypeSbyte);
                Assert.Equal(default(byte), emptyDb.TypeByte);
                Assert.Equal(default(char), emptyDb.TypeChar);
                // nullable byte
                Assert.Equal(null, emptyDb.TypeSbyteN);
                Assert.Equal(null, emptyDb.TypeByteN);
                Assert.Equal(null, emptyDb.TypeCharN);

                // DateTime
                Assert.Equal(default(DateTime), emptyDb.TypeDateTime);
                Assert.Equal(default(DateTimeOffset), emptyDb.TypeDateTimeOffset);
                Assert.Equal(default(TimeSpan), emptyDb.TypeTimeSpan);
                // nullable DateTime
                Assert.Equal(null, emptyDb.TypeDateTimeN);
                Assert.Equal(null, emptyDb.TypeDateTimeOffsetN);
                Assert.Equal(null, emptyDb.TypeTimeSpanN);

                // guid
                Assert.Equal(default(Guid), emptyDb.TypeGuid);
                // nullable guid
                Assert.Equal(null, emptyDb.TypeGuidN);
            };

            const sbyte testSbyte = (sbyte)-128;
            const byte  testByte  = (byte)255;
            const char  testChar  = 'a';
            const float testFloat = (float)1.23456789e38;

            var dateTime       = new DateTime(2016, 10, 11, 1, 2, 3, 456);
            var dateTimeOffset = dateTime + TimeSpan.FromMilliseconds(123.456);
            var timeSpan       = new TimeSpan(1, 2, 3, 4, 5);
            var guid           = Guid.NewGuid();

            // test each data type with a valid value
            // ReSharper disable once ObjectCreationAsStatement
            Func <DataTypesSimple> newValueMem = () => new DataTypesSimple {
                // integers
                TypeShort  = short.MinValue,
                TypeUshort = ushort.MaxValue,
                TypeInt    = int.MinValue,
                TypeUint   = uint.MaxValue,
                TypeLong   = long.MinValue,
                TypeUlong  = ulong.MaxValue,
                // nullable integers
                TypeShortN  = short.MinValue,
                TypeUshortN = ushort.MaxValue,
                TypeIntN    = int.MinValue,
                TypeUintN   = uint.MaxValue,
                TypeLongN   = long.MinValue,
                TypeUlongN  = ulong.MaxValue,

                // decimals
                TypeDecimal = decimal.MaxValue,
                TypeDouble  = double.MaxValue,
                TypeFloat   = testFloat,
                // nullable decimals
                TypeDecimalN = decimal.MaxValue,
                TypeDoubleN  = double.MaxValue,
                TypeFloatN   = testFloat,

                // byte
                TypeSbyte = testSbyte,
                TypeByte  = testByte,
                TypeChar  = testChar,
                // nullable byte
                TypeSbyteN = testSbyte,
                TypeByteN  = testByte,
                TypeCharN  = testChar,

                // DateTime
                TypeDateTime       = dateTime,
                TypeDateTimeOffset = dateTimeOffset,
                TypeTimeSpan       = timeSpan,
                // nullable DateTime
                TypeDateTimeN       = dateTime,
                TypeDateTimeOffsetN = dateTimeOffset,
                TypeTimeSpanN       = timeSpan,

                // guid
                TypeGuid = guid,
                // nullable guid
                TypeGuidN = guid,
            };

            Action <DataTypesSimple> testValue = valueDb =>
            {
                // integers
                Assert.Equal(short.MinValue, valueDb.TypeShort);
                Assert.Equal(ushort.MaxValue, valueDb.TypeUshort);
                Assert.Equal(int.MinValue, valueDb.TypeInt);
                Assert.Equal(uint.MaxValue, valueDb.TypeUint);
                Assert.Equal(long.MinValue, valueDb.TypeLong);
                Assert.Equal(ulong.MaxValue, valueDb.TypeUlong);
                // nullable integers
                Assert.Equal(short.MinValue, valueDb.TypeShortN);
                Assert.Equal(ushort.MaxValue, valueDb.TypeUshortN);
                Assert.Equal(int.MinValue, valueDb.TypeIntN);
                Assert.Equal(uint.MaxValue, valueDb.TypeUintN);
                Assert.Equal(long.MinValue, valueDb.TypeLongN);
                Assert.Equal(ulong.MaxValue, valueDb.TypeUlongN);

                // decimals
                Assert.Equal(decimal.MaxValue, valueDb.TypeDecimal);
                Assert.Equal(double.MaxValue, valueDb.TypeDouble);
                Assert.InRange(valueDb.TypeFloat, testFloat * (1 - 7e-1), testFloat * (1 + 7e-1));         // floats have 7 digits of precision
                // nullable decimals
                Assert.Equal(decimal.MaxValue, valueDb.TypeDecimalN);
                Assert.Equal(double.MaxValue, valueDb.TypeDoubleN);
                Assert.InRange(valueDb.TypeFloatN.GetValueOrDefault(), testFloat * (1 - 7e-1), testFloat * (1 + 7e-1));         // floats have 7 digits of precision

                // byte
                Assert.Equal(testSbyte, valueDb.TypeSbyte);
                Assert.Equal(testByte, valueDb.TypeByte);
                Assert.Equal(testChar, valueDb.TypeChar);
                // nullable byte
                Assert.Equal(testSbyte, valueDb.TypeSbyte);
                Assert.Equal(testByte, valueDb.TypeByteN);
                Assert.Equal(testChar, valueDb.TypeCharN);

                // DateTime
                Assert.Equal(dateTime, valueDb.TypeDateTime);
                Assert.Equal(dateTimeOffset, valueDb.TypeDateTimeOffset);
                Assert.Equal(timeSpan, valueDb.TypeTimeSpan);
                // nullable DateTime
                Assert.Equal(dateTime, valueDb.TypeDateTimeN);
                Assert.Equal(dateTimeOffset, valueDb.TypeDateTimeOffsetN);
                Assert.Equal(timeSpan, valueDb.TypeTimeSpanN);

                // guid
                Assert.Equal(guid, valueDb.TypeGuid);
                // nullable guid
                Assert.Equal(guid, valueDb.TypeGuidN);
            };

            // create test data objects
            var emptyMemAsync = new DataTypesSimple();
            var emptyMemSync  = new DataTypesSimple();
            var valueMemAsync = newValueMem();
            var valueMemSync  = newValueMem();

            // save them to the database
            using (var db = new AppDb()){
                db.DataTypesSimple.Add(emptyMemAsync);
                db.DataTypesSimple.Add(valueMemAsync);
                await db.SaveChangesAsync();

                db.DataTypesSimple.Add(emptyMemSync);
                db.DataTypesSimple.Add(valueMemSync);
                db.SaveChanges();
            }

            // load them from the database and run tests
            using (var db = new AppDb())
            {
                // ReSharper disable once AccessToDisposedClosure
                Func <DataTypesSimple, Task <DataTypesSimple> > fromDbAsync =
                    async dt => await db.DataTypesSimple.FirstOrDefaultAsync(m => m.Id == dt.Id);

                // ReSharper disable once AccessToDisposedClosure
                Func <DataTypesSimple, DataTypesSimple> fromDbSync =
                    dt => db.DataTypesSimple.FirstOrDefault(m => m.Id == dt.Id);

                testEmpty(await fromDbAsync(emptyMemAsync));
                testEmpty(fromDbSync(emptyMemSync));
                testValue(await fromDbAsync(valueMemAsync));
                testValue(fromDbSync(valueMemSync));
            }
        }
Esempio n. 16
0
 public LikeController(AppDb db)
 {
     Db = db;
 }
        public UserDevicesController()
        {
            AppDb db = new AppDb();

            udevRepo = new UserDeviceRespository(db);
        }
Esempio n. 18
0
 public RatingQuery(AppDb db)
 {
     Db = db;
 }
Esempio n. 19
0
 public ftcandcommsController(AppDb db)
 {
     Db = db;
 }
Esempio n. 20
0
 public DashboardController(AppDb db, IUserService userService)
 {
     _db          = db;
     _userService = userService;
 }
 public RestaurantController(AppDb db)
 {
     Db = db;
 }
        public Admin_Relationship_Repo(AppDb repositoryContext)

            : base(repositoryContext)
        {
        }
Esempio n. 23
0
 public AdminLevelRepository(AppDb repositoryContext) : base(repositoryContext)
 {
 }
Esempio n. 24
0
 // Class constructors
 internal Parada(AppDb db)
 {
     Db = db;
 }
Esempio n. 25
0
 public BlogPostQuery(AppDb db)
 {
     Db = db;
 }
Esempio n. 26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              AppDb context,
                              IDataService dataService,
                              ILoggerFactory loggerFactory)
        {
            app.UseForwardedHeaders();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseMigrationsEndPoint();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                if (bool.Parse(Configuration["ApplicationOptions:UseHsts"]))
                {
                    app.UseHsts();
                }
                if (bool.Parse(Configuration["ApplicationOptions:RedirectToHttps"]))
                {
                    app.UseHttpsRedirection();
                }
            }

            app.UseMiddleware <ClickOnceMiddleware>();

            ConfigureStaticFiles(app, env);

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Remotely API V1");
            });

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseCors("TrustedOriginPolicy");

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <AgentHub>("/AgentHub");
                endpoints.MapHub <CasterHub>("/CasterHub");
                endpoints.MapHub <ViewerHub>("/ViewerHub");

                endpoints.MapControllers();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });

            if (context.Database.IsRelational())
            {
                context.Database.Migrate();
            }

            loggerFactory.AddProvider(new DbLoggerProvider(env, app.ApplicationServices));
            dataService.SetAllDevicesNotOnline();
            dataService.CleanupOldRecords();
        }
Esempio n. 27
0
 public ftkeywordController(AppDb db)
 {
     Db = db;
 }
        public ActionResult RegisterUser(RegisterUser newUser)
        {
            if (newUser != null)
            {
                UserAccount user;
                using(AppDb db = new AppDb())
                {
                    if (db.Users.FirstOrDefault(u => u.Email.Equals(newUser.Email)) != null)
                    {
                        //there is already an user with this email address
                        ViewData.ModelState.AddModelError("Email", "Diese E-Mail Adresse wird bereits von einem anderen Spieler genutzt!");
                        return View("register", newUser);
                    }
                    if(!newUser.Password.Equals(newUser.Password2))
                    {
                        //the passwords provieded by the user do not match
                        ViewData.ModelState.AddModelError("Password", "Die angegebenen Passwörter stimmen nicht überein!");
                        return View("register", newUser);
                    }
                    user = new UserAccount()
                    {
                        Admin = false,
                        Picture = "/Content/static/img/unknown_user.png",
                        DisplayName = newUser.Displayname,
                        Email = newUser.Email,
                        LastSeen = DateTime.Now,
                        Registered = DateTime.Now,
                        Enabled = true,
                        Password = GenerateMD5(newUser.Password),
                        Achievements = new LinkedList<Achievement>(),
                        RaceBets = new LinkedList<RaceBet>(),
                        Badges = new LinkedList<Badge>()
                    };
                    db.Users.Add(user);

                    //add player to current season
                    Season currentSeason = db.Seasons.FirstOrDefault(s => s.Year.Equals(DateTime.Now.Year));
                    currentSeason.Players.Add(user);

                    db.SaveChanges();
                }
                //user created successful, redirect to welcome page
                return View("welcome", user);
            }
            return View("register");
        }
        public Menu_Permission_Repository(AppDb reposityContext)

            : base(reposityContext)
        {
        }
Esempio n. 30
0
 public position_repo(AppDb repositoryContext)
     : base(repositoryContext)
 {
 }
Esempio n. 31
0
 internal DataProviderBase(AppDb db)
 {
     Db = db;
 }
Esempio n. 32
0
        //static readonly TalentRepository repository = new TalentRepository();

        //[HttpGet]
        //public IEnumerable<Talent> GetAllTalents()
        //{
        //    return repository.GetAll();
        //}

        //[HttpGet("{id}")]
        //public Talent GetTalent(int id)
        //{
        //    Talent item = repository.Get(id);
        //    if (item == null)
        //    {
        //        throw new System.Web.Http.HttpResponseException(HttpStatusCode.NotFound);
        //    }
        //    return item;
        //}

        public TalentsController(AppDb db)
        {
            Db = db;
        }
Esempio n. 33
0
 public PlaylistController(AppDb db)
 {
     Db = db;
 }
Esempio n. 34
0
 public static DbUsers One(AppDb context, string AuthorizationKey)
 {
     return(context.Users.FirstOrDefault(m => m.AuthorizationKey == AuthorizationKey));
 }