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(); } }
public ActionResult DeleteConfirmed(int id) { donut donut = db.donuts.Find(id); db.donuts.Remove(donut); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool exactMatch(donut rhsDonut) { if (this.shape == rhsDonut.shape && this.flavor == rhsDonut.flavor) { return(true); } return(false); }
public bool anyMatch(donut rhsDonut) { if (this.shape == rhsDonut.shape || this.flavor == rhsDonut.flavor) { return(true); } return(false); }
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); } }
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); } }
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)); }
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); } }
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); } }
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); } }
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)); }
public bool matchColor(donut rhsDonut) { if (!isSettled || matched) { return(false); } if (this.flavor == rhsDonut.getFlavor()) { Debug.Log("Flavor: " + flavor); return(true); } return(false); }
public bool matchShape(donut rhsDonut) { if (!isSettled || matched) { return(false); } if (this.shape == rhsDonut.getShape()) { Debug.Log("Shape: " + shape); return(true); } return(false); }
// 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)); }
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); }
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(); } }
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); }
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); }