Ejemplo n.º 1
0
        public void AddDOnutToDatabase()
        {
            //OpenSqlConnection();



            using (DataClasses1DataContext database = new DataClasses1DataContext(S.GetString()))
            {
                donut donut = new donut();
                donut.donut_id   = 2;
                donut.donut_name = "FilledWithJoy";
                donut.filling    = "Joy";
                donut.price      = 8;
                donut.quantity   = 0;



                database.donut.InsertOnSubmit(donut);
                database.SubmitChanges();



                donut mydonut = database.donut.FirstOrDefault(doonut => doonut.donut_id.Equals(2));
                Assert.AreEqual(mydonut.donut_id, 2);
                Assert.AreEqual(mydonut.donut_name, "FilledWithJoy");
                Assert.AreEqual(mydonut.filling, "Joy");
                Assert.AreEqual(mydonut.price, 8);
                Assert.AreEqual(mydonut.quantity, 0);



                database.donut.DeleteOnSubmit(donut);
                database.SubmitChanges();
            }
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            donut donut = db.donuts.Find(id);

            db.donuts.Remove(donut);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public bool exactMatch(donut rhsDonut)
 {
     if (this.shape == rhsDonut.shape && this.flavor == rhsDonut.flavor)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
 public bool anyMatch(donut rhsDonut)
 {
     if (this.shape == rhsDonut.shape || this.flavor == rhsDonut.flavor)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 static public bool updateQuantity(int id, int?amount)
 {
     using (DataClasses1DataContext context = new DataClasses1DataContext())
     {
         donut mydonut = context.donut.SingleOrDefault(donut => donut.donut_id == id);
         mydonut.quantity = amount;
         context.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 6
0
 static public bool updatePrice(int id, int?cost)
 {
     using (DataClasses1DataContext context = new DataClasses1DataContext())
     {
         donut mydonut = context.donut.SingleOrDefault(donut => donut.donut_id == id);
         mydonut.price = cost;
         context.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "donutID,date,ordered,sold,wasted,name,production,price")] donut donut)
 {
     if (ModelState.IsValid)
     {
         db.Entry(donut).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(donut));
 }
Ejemplo n.º 8
0
 static public bool updateFilling(int id, string fill)
 {
     using (DataClasses1DataContext context = new DataClasses1DataContext())
     {
         donut mydonut = context.donut.SingleOrDefault(donut => donut.donut_id == id);
         mydonut.filling = fill;
         context.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 9
0
 static public bool updateName(int id, string name)
 {
     using (DataClasses1DataContext context = new DataClasses1DataContext())
     {
         donut mydonut = context.donut.SingleOrDefault(donut => donut.donut_id == id);
         mydonut.donut_name = name;
         context.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 10
0
 static public bool deleteDonut(int id)
 {
     using (DataClasses1DataContext context = new DataClasses1DataContext())
     {
         donut mydonut = context.donut.SingleOrDefault(donut => donut.donut_id == id); //tu patrzyłam na różne metody żeby zmienić ale tylko ta się nadaje
         context.donut.DeleteOnSubmit(mydonut);
         context.SubmitChanges();
         return(true);
     }
 }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "donutID,date,ordered,sold,wasted,name,production,price")] donut donut)
        {
            if (ModelState.IsValid)
            {
                db.donuts.Add(donut);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(donut));
        }
Ejemplo n.º 12
0
 public bool matchColor(donut rhsDonut)
 {
     if (!isSettled || matched)
     {
         return(false);
     }
     if (this.flavor == rhsDonut.getFlavor())
     {
         Debug.Log("Flavor: " + flavor);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 13
0
 public bool matchShape(donut rhsDonut)
 {
     if (!isSettled || matched)
     {
         return(false);
     }
     if (this.shape == rhsDonut.getShape())
     {
         Debug.Log("Shape: " + shape);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 14
0
        // GET: donuts/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            donut donut = db.donuts.Find(id);

            if (donut == null)
            {
                return(HttpNotFound());
            }
            return(View(donut));
        }
Ejemplo n.º 15
0
        static public Dictionary <string, string> GetDonutInfo(int donut_id)

        {
            Dictionary <string, string> temp = new Dictionary <string, string>();
            donut t = GetDonut(donut_id);

            temp.Add("name", t.donut_name);
            temp.Add("id", t.donut_id.ToString());
            temp.Add("filling", t.filling);
            temp.Add("price", t.price.ToString());
            temp.Add("quantity", t.quantity.ToString());


            return(temp);
        }
Ejemplo n.º 16
0
        public void ConnectingToNonExsistingDB()
        {
            using (DataClasses1DataContext fake = new DataClasses1DataContext("Data Source = DESKTOP-H5C7HVQ; Initial Catalog = NoNexistant; Integrated Security = True"))
            //using (DataClasses1DataContext fake = new DataClasses1DataContext(S.GetString()))
            {
                donut donut = new donut();
                donut.donut_id   = 2;
                donut.donut_name = "FilledWithJoy";
                donut.filling    = "Joy";
                donut.price      = 8;
                donut.quantity   = 0;



                fake.donut.InsertOnSubmit(donut);
                fake.SubmitChanges();
            }
        }
Ejemplo n.º 17
0
 public bool isMatch(donut rhsDonut)
 {
     if (!isSettled || matched)
     {
         return(false);
     }
     if ((rhsDonut.potentialMatch == 0 || rhsDonut.potentialMatch == 1) && (this.flavor == rhsDonut.flavor))
     {
         Debug.Log("Flavor: " + flavor);
         rhsDonut.potentialMatch = 1;
         return(true);
     }
     if ((rhsDonut.potentialMatch == 0 || rhsDonut.potentialMatch == 2) && (this.shape == rhsDonut.shape))
     {
         Debug.Log("Shape: " + shape);
         rhsDonut.potentialMatch = 2;
         return(true);
     }
     rhsDonut.potentialMatch = 0;
     return(false);
 }
Ejemplo n.º 18
0
        static public bool addDonut(int id, int?amount, string name, string fill, int?cost)
        {
            using (DataClasses1DataContext context = new DataClasses1DataContext())
            {
                if (GetDonut(id) == null && amount >= 0)
                {
                    donut newDonut = new donut
                    {
                        donut_id   = id,
                        donut_name = name,
                        filling    = fill,
                        price      = cost,
                        quantity   = amount,
                    };
                    context.donut.InsertOnSubmit(newDonut);
                    context.SubmitChanges();

                    return(true);
                }
            }
            return(false);
        }