Пример #1
0
        public JsonResult UpdateCategory(APICategory _category)
        {
            var restResult = new RestModel();

            try
            {
                category updateModel = new Models.category();

                updateModel = db.categories.Find(_category.id);

                updateModel.name = _category.name;

                db.Entry(updateModel).State = EntityState.Modified;
                db.SaveChanges();

                restResult.status = true;
            }
            catch (Exception ex)
            {
                restResult.status  = false;
                restResult.message = ex.Message;
            }

            return(Json(restResult, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public void TestAddCouponInterests()
        {
            using (basicEntities be = new basicEntities())
            {
                owner = TestOwner.AddOwner("owner123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                admin = TestAdmin.AddAdmin("admin123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                b     = TestBusiness.AddBusinesses("123", admin, owner, "beer-Sheva", "bla", Category.CarsAccessories);
                cop   = TestCoupon.CreateCoupon(2, "Fly PIZZA", "100", "40", b, "10/10/2014", 8);

                be.Users.Add(owner);
                be.Users.Add(admin);
                be.Businesses.Add(b);
                be.Coupons.Add(cop);
                be.SaveChanges();


                ci = new CouponInterests();

                ci.CouponId   = cop.Id;
                ci.InterestID = InterestType.Dancing;


                be.CouponInterests.Add(ci);
                be.SaveChanges();


                Assert.AreEqual(be.CouponInterests.Find(ci.InterestID, ci.CouponId).CouponId, ci.CouponId);
            }
        }
Пример #3
0
        public void TestRemoveVisit()
        {
            using (basicEntities be = new basicEntities())
            {
                visit      = new Visit();
                visit.Id   = 1;
                visit.Date = "01/01/2004";
                Location l = new Location();
                l.Longitude    = 34.791462;
                l.Latitude     = 31.252973;
                visit.Location = l;
                ((Customer)customer).Visits.Add(visit);
                be.Users.Add(customer);
                be.Visits.Add(visit);

                be.SaveChanges();


                be.Visits.Remove(be.Visits.Find(visit.Id));
                be.Users.Remove(be.Users.Find("customer"));
                be.Locations.Remove(be.Locations.Find(l.Id));
                be.SaveChanges();


                Assert.IsNull(be.Visits.Find(visit.Id));
            }
        }
Пример #4
0
        public void TestAddOrderedCoupon()
        {
            using (basicEntities be = new basicEntities())
            {
                owner    = TestOwner.AddOwner("owner123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                admin    = TestAdmin.AddAdmin("admin123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                b        = TestBusiness.AddBusinesses("123", admin, owner, "beer-Sheva", "bla", Category.CarsAccessories);
                cop      = TestCoupon.CreateCoupon(2, "Fly PIZZA", "100", "40", b, "10/10/2014", 8);
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                be.Users.Add(owner);
                be.Users.Add(admin);
                be.Businesses.Add(b);
                be.Coupons.Add(cop);
                be.SaveChanges();

                oc              = new OrderedCoupon();
                oc.SerialNum    = 4;
                oc.Status       = StatusType.NotUsed;
                oc.PurchaseDate = "27/04/1990";
                oc.Coupon       = cop;
                oc.UseDate      = "";
                oc.Rank         = "0";
                oc.Opinion      = "";
                oc.Customer     = customer;

                be.OrderedCoupons.Add(oc);
                be.SaveChanges();


                Assert.AreEqual(be.OrderedCoupons.Find(oc.SerialNum).PurchaseDate, oc.PurchaseDate);
            }
        }
Пример #5
0
        public JsonResult UpdateProduct(APIProduct _product)
        {
            var restResult = new RestModel();

            try
            {
                product updateModel = new product();
                updateModel = db.products.Find(_product.id);

                updateModel.cat_id = _product.cat_id;
                updateModel.name   = _product.name;
                updateModel.price  = _product.price;
                updateModel.img    = _product.img;
                updateModel.note   = _product.note;

                db.Entry(updateModel).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                restResult.status = true;
            }
            catch (Exception ex)
            {
                restResult.status  = false;
                restResult.message = ex.Message;
            }

            return(Json(restResult, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public void TestRemoveCustomerInterests()
        {
            using (basicEntities be = new basicEntities())
            {
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                be.Users.Add(customer);

                be.SaveChanges();

                ci = new CustomerIntrests();

                ci.InterestID       = InterestType.Dancing;
                ci.CustomerUserName = customer.UserName;

                be.CustomerIntrests.Add(ci);
                be.SaveChanges();



                CustomerIntrests c = be.CustomerIntrests.Find(ci.CustomerUserName, ci.InterestID);

                if (c != null)
                {
                    be.CustomerIntrests.Remove(c);
                    be.Users.Remove(be.Users.Find(customer.UserName));
                    be.SaveChanges();
                }
            }
        }
Пример #7
0
        public void TestRemoveRecommendation()
        {
            using (basicEntities be = new basicEntities())
            {
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                rec             = new Recommendation();
                rec.Description = "blabla";
                rec.Id          = 4;
                rec.Link        = "www.google.com";
                rec.Source      = SourceType.GooglePlus;

                rec.Customer = customer;
                be.Users.Add(customer);
                be.Recommendations.Add(rec);
                be.SaveChanges();


                be.Recommendations.Remove(rec);
                be.Users.Remove(be.Users.Find(customer.UserName));
                be.SaveChanges();

                Assert.IsNull(be.Recommendations.Find(rec.Id));
            }
        }
Пример #8
0
 public static void RemoveCoupon(int CouponID)
 {
     using (basicEntities be = new basicEntities())
     {
         Coupon.Coupon CouponToRemove = be.Coupons.Find(CouponID);
         string        Businessid     = CouponToRemove.Business.BusinessID;
         be.Coupons.Remove(CouponToRemove);
         be.SaveChanges();
         TestBusiness.RemoveBusinesses(Businessid);
         be.SaveChanges();
     }
 }
Пример #9
0
        public ActionResult Create([Bind(Include = "id,cat_id,name,price,img,is_deleted")] product product)
        {
            if (ModelState.IsValid)
            {
                db.products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.cat_id = new SelectList(db.categories, "id", "name", product.cat_id);
            return(View(product));
        }
Пример #10
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Coupons.Find(coupon) != null)
         {
             be.Coupons.Remove(be.Coupons.Find(coupon));
             be.SaveChanges();
             TestBusiness.RemoveBusinesses(Businessid);
             be.SaveChanges();
         }
     }
 }
Пример #11
0
        public static void RemoveBusinesses(string BusinessID)
        {
            using (basicEntities be = new basicEntities())
            {
                Business BusinessesToRemove = be.Businesses.Find(BusinessID);
                string   owner = BusinessesToRemove.Admin.UserName;
                string   admin = BusinessesToRemove.Owner.UserName;
                be.Businesses.Remove(BusinessesToRemove);

                be.SaveChanges();
                TestOwner.RemoveOwner(owner);
                TestAdmin.RemoveAdmin(admin);
                be.SaveChanges();
            }
        }
Пример #12
0
        public ActionResult Create([Bind(Include = "id,name,is_deleted")] category category)
        {
            if (ModelState.IsValid)
            {
                db.categories.Add(new category
                {
                    is_deleted = 0,
                    name       = category.name
                });
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Пример #13
0
        public void TestRemoveLocation()
        {
            using (basicEntities be = new basicEntities())
            {
                loc = new Location();

                loc.Id        = 4;
                loc.Longitude = 34.791462;
                loc.Latitude  = 31.252973;
                be.Locations.Add(loc);
                be.SaveChanges();

                be.Locations.Remove(be.Locations.Find(loc.Id));
                be.SaveChanges();
                Assert.IsNull(be.Locations.Find(loc.Id));
            }
        }
Пример #14
0
        public void TestUpdateLocation()
        {
            using (basicEntities be = new basicEntities())
            {
                loc = new Location();

                loc.Id        = 4;
                loc.Longitude = 34.791462;
                loc.Latitude  = 31.252973;
                be.Locations.Add(loc);
                be.SaveChanges();

                loc.Longitude = 34.791462;
                loc.Latitude  = 35;
                be.SaveChanges();
                Assert.AreEqual(be.Locations.Find(loc.Id).Latitude, loc.Latitude);
            }
        }
Пример #15
0
 public static void RemoveUser(string user)
 {
     using (basicEntities be = new basicEntities())
     {
         User userToRemove = be.Users.Find(user);
         be.Users.Remove(userToRemove);
         be.SaveChanges();
     }
 }
Пример #16
0
 public static string TestOwnerAdd()
 {
     using (basicEntities be = new basicEntities())
     {
         Owner o = AddOwner("owner123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
         be.Users.Add(o);
         be.SaveChanges();
         return(o.UserName);
     }
 }
Пример #17
0
 public static string TestUserAdd()
 {
     using (basicEntities be = new basicEntities())
     {
         User u = AddUser("User123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
         be.Users.Add(u);
         be.SaveChanges();
         return(u.UserName);
     }
 }
Пример #18
0
        public static void RemoveAdmin(string admin)
        {
            using (basicEntities be = new basicEntities())
            {
                User AdminToRemove = be.Users.Find(admin);

                be.Users.Remove(AdminToRemove);
                be.SaveChanges();
            }
        }
Пример #19
0
        public string TestCustomerAdd()
        {
            using (basicEntities be = new basicEntities())
            {
                Customer c = AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                be.Users.Add(c);
                be.SaveChanges();

                return(c.UserName);
            }
        }
Пример #20
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Locations.Find(loc.Id) != null)
         {
             be.Locations.Remove(be.Locations.Find(loc.Id));
             be.SaveChanges();
         }
     }
 }
Пример #21
0
        public static string TestAdminAdd()
        {
            using (basicEntities be = new basicEntities())
            {
                Admin A = AddAdmin("Admin123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                be.Users.Add(A);
                be.SaveChanges();

                return(A.UserName);
            }
        }
Пример #22
0
        public void TestUpdateBusiness()
        {
            using (basicEntities be = new basicEntities())
            {
                Businessid = TestBusinessAdd();

                be.Businesses.Find(Businessid).Address = "tel ron";
                be.SaveChanges();

                Assert.AreEqual(be.Businesses.Find(Businessid).Address, "tel ron");
            }
        }
Пример #23
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Businesses.Find(Businessid) != null)
         {
             be.Businesses.Remove(be.Businesses.Find(Businessid));
             be.SaveChanges();
             TestOwner.RemoveOwner(owners);
             TestAdmin.RemoveAdmin(admins);
         }
     }
 }
Пример #24
0
        public void TestAddCustomerInterests()
        {
            using (basicEntities be = new basicEntities())
            {
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                be.Users.Add(customer);

                be.SaveChanges();

                ci = new CustomerIntrests();

                ci.InterestID       = InterestType.Dancing;
                ci.CustomerUserName = customer.UserName;

                be.CustomerIntrests.Add(ci);
                be.SaveChanges();


                Assert.AreEqual(be.CustomerIntrests.Find(ci.CustomerUserName, ci.InterestID).CustomerUserName, ci.CustomerUserName);
            }
        }
Пример #25
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Visits.Find(visit.Id) != null)
         {
             be.Visits.Remove(be.Visits.Find(visit.Id));
             be.Users.Remove(be.Users.Find("customer"));
             be.Locations.Remove(be.Locations.Find(l.Id));
             be.SaveChanges();
         }
     }
 }
Пример #26
0
        public void TestUpdateUser()
        {
            using (basicEntities be = new basicEntities())
            {
                string username = TestUserAdd();

                be.Users.Find(username).Name = "sos";
                be.SaveChanges();

                Assert.AreEqual(be.Users.Find(username).Name, "sos");
                RemoveUser(username);
            }
        }
Пример #27
0
        public int TestCouponAdd()
        {
            TestBusiness bn = new TestBusiness();

            Businessid = bn.TestBusinessAdd();
            using (basicEntities be = new basicEntities())
            {
                Business      b   = be.Businesses.Find(Businessid);
                Coupon.Coupon cop = CreateCoupon(2, "Fly PIZZA", "100", "40", b, "10/10/2014", 8);
                be.Coupons.Add(cop);
                be.SaveChanges();
                return(cop.Id);
            }
        }
Пример #28
0
        public void CleanUp()
        {
            using (basicEntities be = new basicEntities())
            {
                CustomerIntrests c = be.CustomerIntrests.Find(ci.CustomerUserName, ci.InterestID);

                if (c != null)
                {
                    be.CustomerIntrests.Remove(c);
                    be.Users.Remove(be.Users.Find(customer.UserName));
                    be.SaveChanges();
                }
            }
        }
Пример #29
0
        public void TestUpdateCustomerPhoneKidumet()
        {
            string username = TestCustomerAdd();

            using (basicEntities be = new basicEntities())
            {
                User user = be.Users.Find(username);
                user.PhoneKidomet = 052;
                be.SaveChanges();

                Assert.AreEqual(be.Users.Find(username).PhoneKidomet, 052);
            }
            RemoveCustomer(username);
        }
Пример #30
0
        public void TestUpdatePhoneCustomer()
        {
            string username = TestCustomerAdd();

            using (basicEntities be = new basicEntities())
            {
                User user = be.Users.Find(username);
                user.PhoneNum = 2222222;
                be.SaveChanges();

                Assert.AreEqual(be.Users.Find(username).PhoneNum, 2222222);
            }
            RemoveCustomer(username);
        }