Exemple #1
0
        public void CreateAndInsertIntoPantryTable()
        {
            var db            = new DatabaseStuff();
            var PantryColumns = new List <string>()
            {
                "Pantry_Id int not null identity(1,1) primary key",
                "Name nvarchar(60) not null",
                "Ounces_Consumed decimal(6,2) not null",
                "Ounces_Remaining decimal(6,2) not null",
                "Expired int not null",
                "Expiring_Soon int not null",
                "Restock_Required int not null"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "Pantry", PantryColumns);
                var pan = new Pantry();
                pan.Pantry_Id        = 1;
                pan.Name             = "Bread Flour";
                pan.Ounces_Consumed  = 32.4m;
                pan.Ounces_Remaining = 47.6m;
                pan.Expired          = 0;
                pan.Expiring_Soon    = 0;
                pan.Restock_Required = 0;
                context.Pantry.Add(pan);
                context.SaveChanges();

                var pantryCount =
                    (from p in context.Pantry
                     select p).Count();
                Assert.AreEqual(1, pantryCount);
            }
        }
Exemple #2
0
        public void CreateAndINsertIntoRecipeInformationTable()
        {
            var db             = new DatabaseStuff();
            var RecipesColumns = new List <string>()
            {
                "Id int not null identity(1,1) primary key",
                "Name nvarchar(80) not null",
                "Yield int not null",
                "TotalPrice decimal(7,2) not null",
                "PricePerYield decimal(5,2) not null",
                "HaveEnoughToMakeCurrently int not null"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "Recipes", RecipesColumns);
                var R = new Recipes();
                R.Id                        = 1;
                R.Name                      = "Honeywheat Bread";
                R.Yield                     = 24;
                R.TotalPrice                = 0m;
                R.PricePerYield             = 0m;
                R.HaveEnoughToMakeCurrently = 1;
                context.Recipes.Add(R);
                context.SaveChanges();

                var recipesCount = (from r in context.Recipes
                                    select r).Count();

                Assert.AreEqual(1, recipesCount);
            }
        }
Exemple #3
0
        public void CreateAndInsertIntoIngredientsTable()
        {
            var db = new DatabaseStuff();
            var IngredientsColumns = new List <string>()
            {
                "Id int not null identity(1,1) primary key",
                "Name nvarchar(70)",
                "Recipe_Id int",
                "Measurement nvarchar(70)",
                "Type nvarchar(50)",
                "Classification nvarchar(50)",
                "Selling_Weight nvarchar(50)"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "Ingredients", IngredientsColumns);
                var Ing = new Ingredients();
                Ing.Id             = 1;
                Ing.Name           = "Bread Flour";
                Ing.Measurement    = "6 cups";
                Ing.Selling_Weight = "5 lb";
                Ing.Recipe_Id      = 1;
                Ing.Type           = "Bread Flour";
                context.Ingredients.Add(Ing);
                context.SaveChanges();

                var ingredientsCount =
                    (from i in context.Ingredients
                     select i).Count();
                Assert.AreEqual(1, ingredientsCount);
            }
        }
Exemple #4
0
        public void CreateAndInsertIntoCostsTable()
        {
            var db           = new DatabaseStuff();
            var CostsColumns = new List <string>()
            {
                "Id int not null identity(1,1) primary key",
                "Name nvarchar(70) not null",
                "Selling_Price decimal(6,2) not null",
                "Selling_Weight nvarchar(50) not null",
                "Selling_Weight_Ounces decimal(6,2) not null",
                "Count_Ingredient_Recorded_In_Costs int not null",
                "Average_Price decimal(6,2) not null"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "Costs", CostsColumns);
                var costs = new Costs();
                costs.Id                    = 1;
                costs.Name                  = "Bread Flour";
                costs.Selling_Price         = 4.69m;
                costs.Selling_Weight        = "5 lb";
                costs.Selling_Weight_Ounces = 80m;
                costs.Count_Ingredient_Recorded_In_Costs = 1;
                costs.Average_Price = 4.69m;
                context.Costs.Add(costs);
                context.SaveChanges();

                var costsCount =
                    (from c in context.Costs
                     select c).Count();

                Assert.AreEqual(1, costsCount);
            }
        }
Exemple #5
0
        public void CreateAndInsertIntoSellingInformationTable()
        {
            var db = new DatabaseStuff();
            var SellingInformationColumns = new List <string>()
            {
                "Id int not null identity(1,1) primary key",
                "Name nvarchar(80) not null",
                "Selling_Weight nvarchar(50) not null",
                "Selling_Weight_Ounces decimal(6,2)"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "SellingInformation", SellingInformationColumns);
                var SI = new SellingInformation();
                SI.Id                    = 1;
                SI.Name                  = "Bread Flour";
                SI.Selling_Weight        = "5 lb";
                SI.Selling_Weight_Ounces = 80m;
                context.SellingInformation.Add(SI);
                context.SaveChanges();

                var sellingInformationCount = (from s in context.SellingInformation
                                               select s).Count();
                Assert.AreEqual(1, sellingInformationCount);
            }
        }
Exemple #6
0
        public void CreateAndINsretIntoIngredientConsumptionTable()
        {
            var db = new DatabaseStuff();
            var IngredientConsumptionColumns = new List <string>()
            {
                "Id int not null identity(1,1) primary key",
                "Name nvarchar(70) not null",
                "Measurement nvarchar(70) not null",
                "Ounces_Consumed decimal(6,2)"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "IngredientConsumption", IngredientConsumptionColumns);
                var con = new IngredientConsumption();
                con.Name            = "Bread Flour";
                con.Id              = 1;
                con.Ounces_Consumed = 32.4m;
                //con.Measurement = "6 cups";
                con.Measurement = "6 cups";
                context.IngredientConsumption.Add(con);
                context.SaveChanges();

                var ingredientConsumptionCount =
                    (from c in context.IngredientConsumption
                     select c).Count();

                Assert.AreEqual(1, ingredientConsumptionCount);
            }
        }
        public SmsResponse PingmePleasebySms(SmsRequest smsRequest)
        {
            SmsResponse   smsResponse = new SmsResponse();
            DatabaseStuff databaseStuff = new DatabaseStuff();
            string        request, response, streamResponse;

            try
            {
                #region for wcf basic auth services
                var hostIdentity    = WindowsIdentity.GetCurrent().Name;
                var primaryIdentity = ServiceSecurityContext.Current.PrimaryIdentity.Name;
                var windowsIdentity = ServiceSecurityContext.Current.WindowsIdentity.Name;
                var threadIdentity  = Thread.CurrentPrincipal.Identity.Name;
                //var isAdmin = Thread.CurrentPrincipal.IsInRole("admin");
                #endregion

                //todo: Implement the sms stuff in the wcf service
            }
            catch (Exception ex)
            {
                smsResponse.Success           = false;
                smsResponse.Message           = "An error has occurred: " + ex.Message;
                smsResponse.ApiMessageId      = null;
                smsResponse.SubmittedDateTime = null;
            }

            return(smsResponse);
        }
Exemple #8
0
        public async void SearchCommandExecuted(object param)
        {
            _searchingDb = true;
            DatabaseSearchResults.Clear();

            if (String.IsNullOrEmpty(FirstName.Trim()))
            {
                FirstName = String.Empty;
            }
            if (String.IsNullOrEmpty(LastName.Trim()))
            {
                FirstName = String.Empty;
            }
            if (String.IsNullOrEmpty(StreetAddress.Trim()))
            {
                StreetAddress = String.Empty;
            }
            if (String.IsNullOrEmpty(City.Trim()))
            {
                City = String.Empty;
            }
            if (String.IsNullOrEmpty(ZipCode.Trim()))
            {
                ZipCode = String.Empty;
            }

            Parallel.ForEach((await DatabaseStuff.RunQuery(FirstName, LastName,
                                                           (UseDateOfBirth ? DateOfBirth : DateTime.MinValue), DobEqual, DobAfter, DobBefore, StreetAddress, City, ZipCode)), personModel =>
                             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                                                                                   DatabaseSearchResults.Add(personModel)
                                                                                   ))
                             );
            _searchingDb = false;
        }
 private async void RunSpouseQuery(FacebookLinkModel facebookLinkModel)
 {
     if (!String.IsNullOrEmpty(facebookLinkModel.MarriedTo))
     {
         facebookLinkModel.PossibleSpouseLinks =
             await DatabaseStuff.RunQuery(facebookLinkModel.SpouseFirstName,
                                          facebookLinkModel.SpouseLastName, facebookLinkModel.CurrentCity);
     }
 }
Exemple #10
0
 public ActionResult IDTest()
 {
     using (var context = new RachelsRosesMobileDevelopmentEntities()) {
         var db = new DatabaseStuff();
         db.RecreateDatabase(context);
         var IngDen = new IngredientDensities();
         try {
             IngDen.Name    = "all purpose flour";
             IngDen.Density = 5m;
             //context.IngredientDensities.Add(IngDen);
             context.IngredientDensities.Add(IngDen);
             context.SaveChanges();
         } catch (Exception e) {
             ViewBag.InnerExceptionMessage = e.ToString();
         }
         return(View());
     }
 }
        public async void SearchVoterDBCommandExecuted(object args)
        {
            FacebookLinkModel facebookLinkModel = args as FacebookLinkModel;

            if (facebookLinkModel == null ||
                String.IsNullOrEmpty(facebookLinkModel.CurrentCity) ||
                String.IsNullOrEmpty(facebookLinkModel.CurrentCity))
            {
                MessageBox.Show("You must first scrape facebook before doing sub operations");
                return;
            }

            IsLoading = true;

            SelectedFacebookLinkModel       = facebookLinkModel;
            facebookLinkModel.PossibleLinks =
                await DatabaseStuff.RunQuery(facebookLinkModel.FirstName,
                                             facebookLinkModel.LastName, facebookLinkModel.CurrentCity);

            RunSpouseQuery(facebookLinkModel);

            if (facebookLinkModel.PossibleSpouseLinks != null && facebookLinkModel.PossibleSpouseLinks != null && facebookLinkModel.PossibleLinks.Count > 0 && facebookLinkModel.PossibleSpouseLinks.Count > 0)
            {
                bool matched = false;
                foreach (PersonModel possibleLink in facebookLinkModel.PossibleLinks)
                {
                    if (matched)
                    {
                        break;
                    }

                    foreach (PersonModel possibleSpouseLink in facebookLinkModel.PossibleSpouseLinks)
                    {
                        if (possibleLink.address == possibleSpouseLink.address)
                        {
                            facebookLinkModel.VoterDBMatch      = possibleLink;
                            facebookLinkModel.SouseVoterDBMatch = possibleSpouseLink;
                            matched = true;
                        }
                    }
                }
            }
            IsLoading = false;
        }
        //[PrincipalPermission(SecurityAction.Demand, Role = "admin")]
        public EmailResponse NotifymeThankyoubyEmail(EmailRequest emailRequest)
        {
            EmailResponse emailResponse = new EmailResponse();
            DatabaseStuff databaseStuff = new DatabaseStuff();
            string        request, response;

            try
            {
                #region for wcf basic auth services
                var hostIdentity    = WindowsIdentity.GetCurrent().Name;
                var primaryIdentity = ServiceSecurityContext.Current.PrimaryIdentity.Name;
                var windowsIdentity = ServiceSecurityContext.Current.WindowsIdentity.Name;
                var threadIdentity  = Thread.CurrentPrincipal.Identity.Name;
                //var isAdmin = Thread.CurrentPrincipal.IsInRole("admin");
                #endregion

                var pigeonRequest = EmailFactory.CreatePigeonRequest(emailRequest);

                var pigeonResponse = notifyByPigeon.SendAFitPigeon(pigeonRequest);

                if (pigeonResponse.Success)
                {
                    emailResponse = EmailFactory.CreateEmailResponse(pigeonResponse);

                    request  = CommonUtility.SerializeObject(emailRequest);
                    response = CommonUtility.SerializeObject(emailResponse);

                    var isSaved = databaseStuff.SaveaSomethingAwesome(request, response, 1);
                }
            }
            catch (Exception ex)
            {
                emailResponse.Success           = false;
                emailResponse.Message           = "An error has occurred: " + ex.Message;
                emailResponse.SubmittedDateTime = null;
            }

            return(emailResponse);
        }
Exemple #13
0
        public void CreateAndInsertIntoIngredientDensities2()
        {
            var db = new DatabaseStuff();
            var IngredientDensityColumns = new List <string>()
            {
                "Id int not null identity(1,1) primary key",
                "Name nvarchar(60)",
                "Density decimal(5,2)"
            };

            using (var context = new RachelsRosesMobileDevelopmentEntities()) {
                db.RecreateDatabase(context, "IngredientDensities", IngredientDensityColumns);
                var IngDen = new IngredientDensities();
                IngDen.Id      = 1;
                IngDen.Name    = "bread flour";
                IngDen.Density = 5.4m;
                context.IngredientDensities.Add(IngDen);
                context.SaveChanges();
                var densitiesCount =
                    (from d in context.IngredientDensities
                     select d).Count();
                Assert.AreEqual(1, densitiesCount);
            }
        }
 public Derived(DatabaseStuff d, TimerStuff t, Something <Other> something) : base(d, t)
 {
 public Base(DatabaseStuff d, TimerStuff t)
 {