public int Insert()
        {
            int result = 0;

            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    tblUser user = new tblUser();

                    user.Id             = Guid.NewGuid();
                    user.FirstName      = this.FirstName;
                    user.LastName       = this.LastName;
                    user.BillingAddress = this.BillingAddress;
                    user.Address        = this.Address;
                    user.City           = this.City;
                    user.State          = this.State;
                    user.ZipCode        = this.ZipCode;
                    user.Password       = this.Password;
                    user.Email          = this.Email;


                    dc.tblUsers.Add(user);
                    result = dc.SaveChanges();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int Insert()
        {
            int result = 0;

            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    tblBill bill = new tblBill();
                    bill.Id                = Guid.NewGuid();
                    bill.UserId            = this.UserId;
                    bill.BillDestinationId = this.DesinationId;
                    bill.DueDate           = this.DueDate;
                    bill.BillAmount        = this.BillAmount;
                    bill.PaidOnTime        = this.PaidOnTime;


                    dc.tblBills.Add(bill);
                    result = dc.SaveChanges();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public void LoadById()
        {
            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    if (this.Id != Guid.Empty)
                    {
                        tblPayment make = dc.tblPayments.FirstOrDefault(c => c.Id == this.Id);

                        if (make != null)
                        {
                            this.Id          = make.Id;
                            this.Description = make.Description;
                        }
                        else
                        {
                            throw new Exception("Could not find the row.");
                        }
                    }
                    else
                    {
                        throw new Exception("Id is not set.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void LoadById()
        {
            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    if (this.Id != Guid.Empty)
                    {
                        tblBill bill = dc.tblBills.FirstOrDefault(c => c.Id == this.Id);

                        if (bill != null)
                        {
                            this.Id           = bill.Id;
                            this.UserId       = bill.UserId;
                            this.DueDate      = bill.DueDate;
                            this.BillAmount   = bill.BillAmount;
                            this.PaidOnTime   = bill.PaidOnTime;
                            this.DesinationId = bill.BillDestinationId;
                        }
                        else
                        {
                            throw new Exception("Could not find the row.");
                        }
                    }
                    else
                    {
                        throw new Exception("Id is not set.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void Load()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             dc.tblBills
             .ToList()
             .ForEach(c => this
                      .Add(new Bill
             {
                 Id           = c.Id,
                 DesinationId = c.BillDestinationId,
                 UserId       = c.UserId,
                 DueDate      = c.DueDate,
                 BillAmount   = c.BillAmount,
                 PaidOnTime   = c.PaidOnTime,
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public int Update()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             if (this.Id != Guid.Empty)
             {
                 tblBill bill = dc.tblBills.Where(c => c.Id == this.Id).FirstOrDefault();
                 bill.UserId            = this.UserId;
                 bill.BillDestinationId = this.DesinationId;
                 bill.DueDate           = this.DueDate;
                 bill.BillAmount        = this.BillAmount;
                 bill.PaidOnTime        = this.PaidOnTime;
                 return(dc.SaveChanges());
             }
             else
             {
                 throw new Exception("Id is not set.");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void LoadById()
        {
            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    if (this.Id != Guid.Empty)
                    {
                        tblBillDestination billDestination = dc.tblBillDestinations.FirstOrDefault(c => c.Id == this.Id);

                        if (billDestination != null)
                        {
                            this.Id = billDestination.Id;
                            this.BusinessAddress = billDestination.BusinessAddress;
                            this.BusinessName    = billDestination.BusinessName;
                        }
                        else
                        {
                            throw new Exception("Could not find the row.");
                        }
                    }
                    else
                    {
                        throw new Exception("Id is not set.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void Load()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             dc.tblUsers
             .ToList()
             .ForEach(c => this
                      .Add(new User
             {
                 Id             = c.Id,
                 FirstName      = c.FirstName,
                 LastName       = c.LastName,
                 Address        = c.Address,
                 BillingAddress = c.BillingAddress,
                 City           = c.City,
                 State          = c.State,
                 ZipCode        = c.ZipCode,
                 Password       = c.Password,
                 Email          = c.Email,
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public int Update()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             if (this.Id != Guid.Empty)
             {
                 tblUser user = dc.tblUsers.Where(c => c.Id == this.Id).FirstOrDefault();
                 user.FirstName      = this.FirstName;
                 user.LastName       = this.LastName;
                 user.BillingAddress = this.BillingAddress;
                 user.Address        = this.Address;
                 user.City           = this.City;
                 user.State          = this.State;
                 user.ZipCode        = this.ZipCode;
                 user.Password       = this.Password;
                 user.Email          = this.Email;
                 return(dc.SaveChanges());
             }
             else
             {
                 throw new Exception("Id is not set.");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #10
0
 public void LoadTest()
 {
     using (BudgetManagementEntities dc = new BudgetManagementEntities())
     {
         int expected     = 2;
         var destinations = dc.tblUsers;
         int actual       = destinations.Count();
         Assert.AreEqual(expected, actual);
     }
 }
 public void LoadTest()
 {
     using (BudgetManagementEntities dc = new BudgetManagementEntities())
     {
         int expected = 3;
         var bills    = dc.tblBills;
         int actual   = bills.Count();
         Assert.AreEqual(expected, actual);
     }
 }
 public void LoadTest()
 {
     using (BudgetManagementEntities dc = new BudgetManagementEntities())
     {
         int expected = 4;
         var payments = dc.tblPayments;
         int actual   = payments.Count();
         Assert.AreEqual(expected, actual);
     }
 }
        public void DeleteTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblPayment tblpayment = dc.tblPayments.Where(c => c.Description == "UpdatedPayment").FirstOrDefault();
                dc.tblPayments.Remove(tblpayment);
                dc.SaveChanges();

                tblPayment newpayment = dc.tblPayments.Where(c => c.Description == "UpdatedPayment").FirstOrDefault();

                Assert.IsNull(newpayment);
            }
        }
        public void DeleteTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblBillDestination tblbilldestination = dc.tblBillDestinations.Where(c => c.BusinessName == "Chase").FirstOrDefault();
                dc.tblBillDestinations.Remove(tblbilldestination);
                dc.SaveChanges();

                tblBillDestination newdestination = dc.tblBillDestinations.Where(c => c.BusinessName == "Chase").FirstOrDefault();

                Assert.IsNull(newdestination);
            }
        }
Beispiel #15
0
        public void DeleteTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblUser tbluser = dc.tblUsers.Where(c => c.FirstName == "Jay").FirstOrDefault();
                dc.tblUsers.Remove(tbluser);
                dc.SaveChanges();

                tblUser newuser = dc.tblUsers.Where(c => c.FirstName == "Jay").FirstOrDefault();

                Assert.IsNull(newuser);
            }
        }
        public void DeleteTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblBill tblbill = dc.tblBills.Where(c => c.BillAmount == 100).FirstOrDefault();
                dc.tblBills.Remove(tblbill);
                dc.SaveChanges();

                tblBill newbill = dc.tblBills.Where(c => c.BillAmount == 100).FirstOrDefault();

                Assert.IsNull(newbill);
            }
        }
        public void UpdateTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblPayment tblpayment = dc.tblPayments.Where(c => c.Description == "TestPayment").FirstOrDefault();
                tblpayment.Description = "UpdatedPayment";

                dc.SaveChanges();

                tblPayment newpayment = dc.tblPayments.Where(c => c.Description == "UpdatedPayment").FirstOrDefault();

                Assert.AreNotEqual(newpayment.Description, "TestPayment");
            }
        }
        public void UpdateTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblBillDestination tblbilldestination = dc.tblBillDestinations.Where(c => c.BusinessName == "Chase").FirstOrDefault();
                tblbilldestination.BusinessAddress = "4401 W Wisconsin Ave";

                dc.SaveChanges();

                tblBillDestination newdestination = dc.tblBillDestinations.Where(c => c.BusinessAddress == "4401 W Wisconsin Ave").FirstOrDefault();

                Assert.AreNotEqual(tblbilldestination.BusinessAddress, "111 E Wisconsin Ave");
            }
        }
Beispiel #19
0
        public void UpdateTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblUser tbluser = dc.tblUsers.Where(c => c.Password == "Test1").FirstOrDefault();
                tbluser.Password = "******";

                dc.SaveChanges();

                tblUser newuser = dc.tblUsers.Where(c => c.Password == "TestUpdate").FirstOrDefault();

                Assert.AreNotEqual(tbluser.Password, "Test1");
            }
        }
        public void InsertTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblPayment tblpayment = new tblPayment();
                tblpayment.Id          = Guid.NewGuid();
                tblpayment.Description = "TestPayment";

                dc.tblPayments.Add(tblpayment);
                dc.SaveChanges();

                tblPayment newpayment = dc.tblPayments.Where(c => c.Description == "TestPayment").FirstOrDefault();

                Assert.AreEqual(newpayment.Description, "TestPayment");
            }
        }
        public void InsertTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblBillDestination tblbilldestination = new tblBillDestination();
                tblbilldestination.Id              = Guid.NewGuid();
                tblbilldestination.BusinessName    = "Chase";
                tblbilldestination.BusinessAddress = "111 E Wisconsin Ave";

                dc.tblBillDestinations.Add(tblbilldestination);
                dc.SaveChanges();

                tblBillDestination newdestination = dc.tblBillDestinations.Where(c => c.BusinessName == "Chase").FirstOrDefault();

                Assert.AreEqual(tblbilldestination.BusinessName, newdestination.BusinessName);
            }
        }
Beispiel #22
0
 public void Load()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             dc.tblPayments
             .ToList()
             .ForEach(c => this
                      .Add(new Payment // ??
             {
                 Id          = c.Id,
                 Description = c.Description
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void InsertTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblUser            user        = dc.tblUsers.Where(c => c.FirstName == "Owen").FirstOrDefault();
                tblBillDestination destination = dc.tblBillDestinations.Where(c => c.BusinessName == "Spectrum").FirstOrDefault();
                tblBill            tblbill     = new tblBill();
                tblbill.Id                = Guid.NewGuid();
                tblbill.UserId            = user.Id;
                tblbill.BillDestinationId = destination.Id;
                tblbill.BillAmount        = 50;
                tblbill.DueDate           = new DateTime(2019, 5, 1);
                tblbill.PaidOnTime        = true;

                dc.tblBills.Add(tblbill);
                dc.SaveChanges();

                tblBill newbill = dc.tblBills.Where(c => c.BillAmount == 50).FirstOrDefault();

                Assert.AreEqual(newbill.BillAmount, 50);
            }
        }
        public void LoadById()
        {
            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    if (this.Id != Guid.Empty)
                    {
                        tblUser user = dc.tblUsers.FirstOrDefault(c => c.Id == this.Id);

                        if (user != null)
                        {
                            this.Id             = user.Id;
                            this.FirstName      = user.FirstName;
                            this.LastName       = user.LastName;
                            this.BillingAddress = this.BillingAddress;
                            this.Address        = this.Address;
                            this.City           = this.City;
                            this.State          = this.State;
                            this.ZipCode        = this.ZipCode;
                            this.Password       = this.Password;
                            this.Email          = this.Email;
                        }
                        else
                        {
                            throw new Exception("Could not find the row.");
                        }
                    }
                    else
                    {
                        throw new Exception("Id is not set.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void Load()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             dc.tblBillDestinations
             .ToList()
             .ForEach(c => this
                      .Add(new BillDestination
             {
                 Id = c.Id,
                 BusinessAddress = c.BusinessAddress,
                 BusinessName    = c.BusinessName
             }));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #26
0
        public int Insert()
        {
            int result = 0;

            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    tblPayment make = new tblPayment();
                    make.Id          = Guid.NewGuid();
                    make.Description = this.Description;

                    dc.tblPayments.Add(make);
                    result = dc.SaveChanges();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #27
0
 public int Update()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             if (this.Id != Guid.Empty)
             {
                 tblPayment make = dc.tblPayments.Where(c => c.Id == this.Id).FirstOrDefault();
                 make.Description = this.Description;
                 return(dc.SaveChanges());
             }
             else
             {
                 throw new Exception("Id is not set.");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int Insert()
        {
            int result = 0;

            try
            {
                using (BudgetManagementEntities dc = new BudgetManagementEntities())
                {
                    tblBillDestination billDestination = new tblBillDestination();
                    billDestination.Id              = Guid.NewGuid();
                    billDestination.BusinessName    = this.BusinessName;
                    billDestination.BusinessAddress = this.BusinessAddress;

                    dc.tblBillDestinations.Add(billDestination);
                    result = dc.SaveChanges();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public int Delete()
 {
     try
     {
         using (BudgetManagementEntities dc = new BudgetManagementEntities())
         {
             if (this.Id != Guid.Empty)
             {
                 tblBillDestination billDestination = dc.tblBillDestinations.Where(c => c.Id == this.Id).FirstOrDefault();
                 dc.tblBillDestinations.Remove(billDestination);
                 return(dc.SaveChanges());
             }
             else
             {
                 throw new Exception("Id is not set.");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #30
0
        public void InsertTest()
        {
            using (BudgetManagementEntities dc = new BudgetManagementEntities())
            {
                tblUser tbluser = new tblUser();
                tbluser.Id             = Guid.NewGuid();
                tbluser.FirstName      = "Jay";
                tbluser.LastName       = "Hemes";
                tbluser.Address        = "123 Main Strees";
                tbluser.BillingAddress = "123 Main Street";
                tbluser.City           = "Neenah";
                tbluser.State          = "Wisconsin";
                tbluser.ZipCode        = 54956;
                tbluser.Password       = "******";
                tbluser.Email          = "*****@*****.**";

                dc.tblUsers.Add(tbluser);
                dc.SaveChanges();

                tblUser newuser = dc.tblUsers.Where(c => c.FirstName == "Jay").FirstOrDefault();

                Assert.AreEqual(newuser.FirstName, "Jay");
            }
        }