public IHttpActionResult PutHotDog(int id, HotDog hotdog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hotdog.HotDogId) { return(BadRequest()); } db.Entry(hotdog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HotDogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Kitchen_CreateMainFood() { //arrange ILogger loggerMock = MockRepository.GenerateMock <ILogger>(); Kitchen kitchen = new Kitchen(); Waitress waitress = new Waitress(kitchen, loggerMock); Client client = new Client(150, "Andrew"); Order order = new Order("HOTDOG", new List <string> { "KETCHUP" }, loggerMock); IFood food = new HotDog(); IFood extras = new Ketchup(food); loggerMock.Expect(x => x.Write("Kitchen: Preparing food, order: Order[food=HOTDOG, extras=[KETCHUP]]")); loggerMock.Expect(x => x.Write("Kitchen: Food prepared, food: food=Hotdog, extras=[Ketchup]")); //act var foodFromKitchen = kitchen.CreateMainFood(order.FoodToOrder); var extrasFromKitchen = kitchen.AddExtras(foodFromKitchen, order.ExtrasForAdding); var finalFood = kitchen.Cook(order, loggerMock); //assert //For some reason these asserts dont return true //Assert.AreEqual(food, foodFromKitchen); //Assert.AreEqual(extrasFromKitchen, extras); //Assert.AreEqual(finalFood, extras); loggerMock.VerifyAllExpectations(); }
public ActionResult AddHotDog(HotDog hotDog) { if (ModelState.IsValid) { if (hotDog.Id == 0) { _db.HotDog.Add(hotDog); _db.SaveChanges(); } else { var hotDogToUpdate = _db.HotDog.Single(x => x.Id == hotDog.Id); hotDogToUpdate.Name = hotDog.Name; hotDogToUpdate.Phone = hotDog.Phone; _db.SaveChanges(); } return(RedirectToAction("Index")); } else { var sauces = _db.Sauces.ToList(); HotDogWithSauceViewModel hotDogWithSauceViewModel = new HotDogWithSauceViewModel() { HotDog = hotDog, Sauces = sauces }; return(View("HotDogForm", hotDogWithSauceViewModel)); } }
public void Order_NotifyReady() { //arrange ILogger loggerMock = MockRepository.GenerateMock <ILogger>(); IEvent eventMock = MockRepository.GenerateMock <IEvent>(); IOnFoodReady onFoodReadyMock = MockRepository.GenerateMock <IOnFoodReady>(); Kitchen kitchen = new Kitchen(); Waitress waitress = new Waitress(kitchen, loggerMock); Client client = new Client(150, "Andrew"); Order order = new Order("HOTDOG", new List <string> { "KETCHUP" }, loggerMock); IFood food = new HotDog(); IFood extras = new Ketchup(food); var expectedMessage = "Order: Notifying observers of Order: [food=HOTDOG, extras=KETCHUP]"; loggerMock.Expect(x => x.Write(expectedMessage)); //act order.NotifyReady(extras); loggerMock.VerifyAllExpectations(); }
public HotDogConfigurationPage(HotDog hotDog, bool locationNeedsUpdate) { InitializeComponent(); _hotDog = hotDog; _locationNeedsUpdate = locationNeedsUpdate; }
public async Task <HotDog> AddAsync(HotDog hotDog) { _db.Add(hotDog); await _db.SaveChangesAsync(); return(hotDog); }
public HotDogDetailViewController(IntPtr handle) : base(handle) { //get amy hotdog to fill the view SelectedHotDog = hotDogsDataService.GetHotDog(1); }
static HotDogService() { hotDogs = new List<HotDog>(); HotDog dog1 = new HotDog() { HotDogID = 1, HotDogName = "Frank's All Beef Chillidawg", LastPlaceAte = "Franks", LastTimeAte = new DateTime(), Rating = 5 }; hotDogs.Add(dog1); HotDog dog2 = new HotDog() { HotDogID = 2, HotDogName = "Veronica's Vegan Delight", LastPlaceAte = "Choo Choo Wagon", LastTimeAte = new DateTime(), Rating = 1 }; hotDogs.Add(dog2); HotDog dog3 = new HotDog() { HotDogID = 3, HotDogName = "Heart Attack", LastPlaceAte = "Main Street Cafe", LastTimeAte = new DateTime(), Rating = 3 }; hotDogs.Add(dog3); }
public ActionResult DeleteConfirmed(decimal id) { HotDog hotDog = db.HotDogs.Find(id); db.HotDogs.Remove(hotDog); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddCartItem(HotDog hotDog, int amount) { //TODO: add check if already added MainCart.CartItems.Add(new CartItem() { HotDog = hotDog, Amount = amount }); }
public void GetDogTest() { HotDogService service = new HotDogService(); HotDog dog = service.Get(1); Assert.IsNotNull(dog); Assert.AreEqual("Frank's All Beef Chillidawg", dog.HotDogName); }
public HotDog Get(int id) { HotDog selectedDog = new HotDog(); foreach (HotDog hotdog in hotDogs) { if (hotdog.HotDogID == id) { selectedDog = hotdog; } } return selectedDog; }
public HotDog GetHotDogById(int hotDogId) { HotDog hotDog = hotDodGroups .SelectMany(h => h.HotDogs) .SingleOrDefault(h => h.HotDogId == hotDogId) ; return(hotDog); }
public void HotDogHappinessTest() { IFood food = new HotDog(); double expected = 102; double startingHappiness = 100; double happiness = food.CalculateHappiness(startingHappiness); Assert.AreEqual(happiness, expected); }
public HotDogSQL ConversionToSQL(HotDog hotDog) { string sauce0 = null; if (hotDog.Sauce0 != null) { sauce0 = hotDog.Sauce0.Id; } string sauce1 = null; if (hotDog.Sauce1 != null) { sauce1 = hotDog.Sauce1.Id; } string sauce2 = null; if (hotDog.Sauce2 != null) { sauce2 = hotDog.Sauce2.Id; } string topping0 = null; if (hotDog.Topping0 != null) { topping0 = hotDog.Topping0.Id; } string topping1 = null; if (hotDog.Topping1 != null) { topping1 = hotDog.Topping1.Id; } string topping2 = null; if (hotDog.Topping2 != null) { topping2 = hotDog.Topping2.Id; } HotDogSQL hotDogSQL = new HotDogSQL { Id = hotDog.Id, Bun = hotDog.Bun.Id, Sausage = hotDog.Sausage.Id, Sauce0 = sauce0, Sauce1 = sauce1, Sauce2 = sauce2, Topping0 = topping0, Topping1 = topping1, Topping2 = topping2, Price = hotDog.Price, Order = hotDog.Order }; return(hotDogSQL); }
public ActionResult Edit([Bind(Include = "HotDogID,Name,LastAte,LastPlaceAte")] HotDog hotDog) { if (ModelState.IsValid) { db.Entry(hotDog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hotDog)); }
public async Task <int> CreateAsync(string name, int phone, int sauceid) { var hotDog = new HotDog() { Name = name, Phone = phone, SauceId = sauceid }; await _repo.AddAsync(hotDog); return(hotDog.Id); }
static void Main(string[] args) { Hamburger ham = new Hamburger(); ham.Prepare(); Console.WriteLine(); HotDog hd = new HotDog(); hd.Prepare(); }
public IActionResult Get() { _logger.Warn("Jakiś log "); HotDog hotDog = new HotDog() { Id = 5, Name = "Zwykly", Phone = 6666 }; HotDogDTO HotDogDto = _mapper.Map <HotDogDTO>(hotDog); return(Ok(HotDogDto)); }
public ActionResult Create([Bind(Include = "HotDogID,Name,LastAte,LastPlaceAte")] HotDog hotDog) { if (ModelState.IsValid) { db.HotDogs.Add(hotDog); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hotDog)); }
private void ListViewOnItemClick(object sender, AdapterView.ItemClickEventArgs itemClickEventArgs) { HotDog hotDog = HotDogs[itemClickEventArgs.Position]; Intent intent = new Intent(); intent.SetClass(Activity, typeof(HotDogDetailActivity)); intent.PutExtra("selectedHotDogId", hotDog.HotDogId); StartActivityForResult(intent, 100); }
public IHttpActionResult GetHotDog(int id) { HotDog hotdog = db.HotDogs.Find(id); if (hotdog == null) { return(NotFound()); } return(Ok(hotdog)); }
public override async void HotDogSelected(HotDog selectedHotDog) { HotDogDetailViewController hotDogDetailViewController = this.Storyboard.InstantiateViewController("hotDogDetailViewController") as HotDogDetailViewController; if (hotDogDetailViewController != null) { hotDogDetailViewController.ModalTransitionStyle = UIModalTransitionStyle.PartialCurl; hotDogDetailViewController.SelectedHotDog = selectedHotDog; await PresentViewControllerAsync(hotDogDetailViewController, true); } }
public IHttpActionResult PostHotDog(HotDog hotdog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.HotDogs.Add(hotdog); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = hotdog.HotDogId }, hotdog)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.HotDogDetailView); HotDogDataService dataService = new HotDogDataService(); selectedHotDog = dataService.GetHotDogByID(1); FindViews(); BindData(); }
static void Main(string[] args) { var hotDog = new HotDog(); var hamburger = new Hamburger(); Console.WriteLine("\nHotDog:"); hotDog.Prepare(); Console.WriteLine("\nHamburger:"); hamburger.Prepare(); Console.ReadLine(); }
static void Main(string[] args) { HotDog hotDog = new HotDog(); Burger burger = new Burger(); hotDog.Prepare(); Console.WriteLine(); burger.Prepare(); Console.ReadLine(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.HotDogDetailView); _dataService = new HotDogDataService(); int hotDogId = Intent.Extras.GetInt("selectedHotDogId"); _selectedHotDog = _dataService.GetHotDogById(hotDogId); FindViews(); BindData(); HandleEvents(); // Create your application here }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.HotDogDetailView); dataService = new HotDogDataService(); selectedHotDog = dataService.GetHotDogById(1); // Create your application here FindViews(); BindData(); HandleEvents(); }
public async Task add_hotDog_To_Db() { //Arange HotDog hotDog = new HotDog() { Name = "£agodny", Phone = 666746759, SauceId = 2 }; IRepo repo = new Repos(); //Act var hotDogInDb = await repo.AddAsync(hotDog); //Assert Assert.Equal(hotDogInDb, hotDog); }