public Smoothie Post([FromBody] Smoothie newSmoothie) { if (ModelState.IsValid) { return(db.AddSmoothie(newSmoothie)); } return(null); }
public ActionResult DeleteConfirmed(int id) { Smoothie smoothie = db.icecekler.Find(id); db.icecekler.Remove(smoothie); db.SaveChanges(); return(RedirectToAction("Index")); }
//UPDATE SMOOTHIE public Smoothie Update(Smoothie smoothie) { _db.Execute(@" UPDATE smoothies SET (name, description, price) VALUES (@Name, @Description, @Price) WHERE id = @Id ", smoothie); return(smoothie); }
//Create Smoothie public Smoothie Create(Smoothie smoothie) { int id = _db.ExecuteScalar <int>(@" INSERT INTO smoothies (name, description, price) VALUES (@Name, @Description, @Price); SELECT LAST_INSERT_ID();", smoothie); smoothie.Id = id; return(smoothie); }
public Smoothie AddSmoothie(Smoothie newSmoothie) { int id = _db.ExecuteScalar <int>(@" INSERT INTO smoothies (name, price, description) VALUES(@Name, @Price, @Description); SELECT LAST_INSERT_ID()", newSmoothie); newSmoothie.Id = id; return(newSmoothie); }
public ActionResult Edit([Bind(Include = "Id,SmoothieAdi,Malzemeler,Hazirlanisi,Resim")] Smoothie smoothie) { if (ModelState.IsValid) { db.Entry(smoothie).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(smoothie)); }
public ActionResult Create([Bind(Include = "Id,SmoothieAdi,Malzemeler,Hazirlanisi,Resim")] Smoothie smoothie) { if (ModelState.IsValid) { db.icecekler.Add(smoothie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(smoothie)); }
// GET: Smoothies/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Smoothie smoothie = db.icecekler.Find(id); if (smoothie == null) { return(HttpNotFound()); } return(View(smoothie)); }
public List <string> explore(string fruit1, string fruit2) { Smoothie smoothie = new Smoothie(" ", fruit1, fruit2, true); List <string> potentialSmoothies = new List <string>(); foreach (var item in SmoothieList.Smoothies()) { if (item.fruit1 == smoothie.fruit1 || item.fruit2 == smoothie.fruit2) { potentialSmoothies.Add(item.name); } } return(potentialSmoothies); }
// CREATE NEW Smoothie public Smoothie Create(Smoothie smoothie) { // it returns the id of the record just inserted in the command; takes the item => inserts to database, comes back with the id to keep track of later // the order of the first (name, description, price) doesnt matter so long as the second (@Name, @Description, @Price) lines up in the same order as the first // MySQL will always lowercase column names, etc int id = _db.ExecuteScalar <int>(@" INSERT INTO smoothies (name, description, price) VALUES (@Name, @Description, @Price); SELECT LAST_INSERT_ID();", smoothie ); // execute = can write, query = can read smoothie.Id = id; return(smoothie); }
public string canMake(string fruit1, string fruit2, bool iceOrNot) { Smoothie smoothie = new Smoothie(" ", fruit1, fruit2, iceOrNot); foreach (var item in SmoothieList.Smoothies()) { if (item.fruit1 == smoothie.fruit1 && item.fruit2 == smoothie.fruit2 && item.iceOrNot == smoothie.iceOrNot) { return(item.ToString()); } } return("No smoothie found"); }
public List <Product> Get_all_Products() { List <Product> result = new List <Product>(); List <Product> retrn = new List <Product>(); using (var context = new ShopReviewsdb()) { result = context.Products.Include(s => s.Shop).Include(r => r.Reviews).Include(a => a.Shop.Address).ToList <Product>(); } foreach (Product p in result) { var field = p.GetType().GetField("_entityWrapper"); if (field == null) { retrn.Add(p); } var wrapper = field.GetValue(p); var property = wrapper.GetType().GetProperty("IdentityType").GetValue(wrapper); var name = property.GetType().GetProperty("Name").GetValue(property); Product prod = null; if (name.ToString() == "IceCream") { prod = new IceCream(p); } if (name.ToString() == "FrozenYogurt") { prod = new FrozenYogurt(p); } if (name.ToString() == "Waffle") { prod = new Waffle(p); } if (name.ToString() == "FrenchCrape") { prod = new FrenchCrape(p); } if (name.ToString() == "Smoothie") { prod = new Smoothie(p); } prod.NutritinosValuesDictonary = new GetNutritions().GetProductNutritions(prod.NutritionalValues); retrn.Add(prod); } return(retrn); }
//CREATE Smoothie public Smoothie Create(Smoothie smoothie) { //first @ indicates multi-line input //order of values must matach order of insert statement columns //DON"T USE STRING INTERPOLATION HERE, ESPECIALLY WITH USER INPUT //Smoothie in line 52 is the object that dapper parses and references //from the values parameters two lines above int id = _db.ExecuteScalar <int>(@" INSERT INTO Smoothies (name, description, price) VALUES (@Name, @Description, @Price); SELECT LAST_INSERT_ID();", smoothie ); smoothie.Id = id; return(smoothie); }
/// <summary> /// Saves the medicine item currently being edited. /// </summary> /// <returns>The item.</returns> /// <param name="item">Item.</param> //public int SaveItem(MedicineItem item) public int SaveItem(Smoothie item) { // Set a mutual-exclusive lock on our database, while // saving/updating our medicine item. lock (locker) { if (item.Id != 0) { database.Update(item); return(item.Id); } else { return(database.Insert(item)); } } }
//CREATE SMOOTHIE public Smoothie Create(Smoothie smoothie) { // Dapper used below in VALUES line (The '@' symbol) int id = _db.ExecuteScalar <int>(@" INSERT INTO smoothies (name, description, price) VALUES (@Name, @Description, @Price); SELECT LAST_INSERT_ID();", smoothie ); //Or instead of smoothie, use instead: new { // Name = smoothie.Name, // Description = smoothie.Description, // Price = smoothie.Price // } smoothie.Id = id; return(smoothie); }
public void SmoothieBar_Making10000Smoothies_NutritionValuesAreAlwaysCorrect() { NutritionClinic sut = SetUpTestClinic(); Food testBanana = new Food("banana", 100, 100); for (int i = 0; i < 10000; i++) { Smoothie sutSmoothie = sut.SmoothieBar.MakeSmoothie(testBanana, testBanana); if (sutSmoothie.KcalPerportion != 200) { Assert.Fail(); } if (sutSmoothie.ProteinPerportion != 200) { Assert.Fail(); } } Assert.Pass(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var SmoothieShackShack = new Menu(); var checkout = new CheckoutService(); var bestFriendsMug = new Chachkie() { Name = "Worlds Okayest Friend", Price = 17.99m }; var apple = new Fruit() { Name = "Apple", Price = .5m }; var caffiene = new EnergyShot() { Name = "Double Double", Price = .75m }; var sunrise = new Smoothie() { Name = "Sunrise" }; sunrise.Fruits.Add(apple); sunrise.Shots.Add(caffiene); // SmoothieShackShack.AvailableFruit.Add(apple); // SmoothieShackShack.Shots.Add(caffiene); var jakesOrder = new Order(); jakesOrder.Smoothies.Add(sunrise); jakesOrder.Souvenirs.Add(bestFriendsMug); // jakesOrder.Souvenirs.Add checkout.PrintTotal(jakesOrder); }
public override System.Web.Mvc.ActionResult Summary(System.Web.Mvc.FormCollection form, Smoothie.Domain.Dto.UserDataDto userData, int smoothieId, int category) { var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.Summary); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userData", userData); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "smoothieId", smoothieId); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "category", category); return callInfo; }
//DELETE SMOOTHIE public Smoothie Delete(Smoothie smoothie) { _db.Execute("DELETE FROM smoothies WHERE id = @Id", smoothie); return(smoothie); }
public override System.Web.Mvc.ActionResult Index(Smoothie.Domain.Dto.UserDataDto userData, int category) { var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.Index); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userData", userData); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "category", category); return callInfo; }
public override System.Web.Mvc.ActionResult Signup(Smoothie.Domain.ViewModels.UserRegisterViewModel user) { var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.Signup); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "user", user); return callInfo; }
public override System.Web.Mvc.PartialViewResult UserProfile(Smoothie.Domain.Dto.UserDataDto userData) { var callInfo = new T4MVC_PartialViewResult(Area, Name, ActionNames.UserProfile); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "userData", userData); return callInfo; }