Ejemplo n.º 1
0
        public void SupplyDetail_ObjectCreation_Test(int foodItemCount, String requestDate, string sellerName, double packingCharge)
        {
            FoodDetail   fooditem     = p.CreateFoodDetail("Biriyani", 10, DateTime.Parse("2022/12/02"), 100.00);
            SupplyDetail supplyDetail = p.CreateSupplyDetail(foodItemCount, DateTime.Parse(requestDate), sellerName, packingCharge, fooditem);

            Assert.AreEqual(typeof(SupplyDetail), supplyDetail.GetType());
        }
        public IEnumerable <FoodandNutrition> GetAllNutritions()
        {
            List <FoodDetail>       foods             = _context.FoodDetails.ToList();
            List <FoodandNutrition> foodandNutritions = new List <FoodandNutrition>();

            foreach (var item in _context.Nutritions)
            {
                FoodDetail foodDetail = new FoodDetail();
                foodDetail = foods.FirstOrDefault(f => f.FoodId == item.FoodId);
                if (foodDetail != null)
                {
                    foodandNutritions.Add(new FoodandNutrition
                    {
                        NutritionId           = item.NutritionId,
                        FoodName              = foodDetail.FoodName,
                        WeightInGrams         = item.WeightInGrams,
                        Protein               = item.Protein,
                        Calories              = item.Calories,
                        Totalsugar            = item.Totalsugar,
                        Sodium                = item.Sodium,
                        Grain                 = item.Grain,
                        FruitorVegetable      = item.FruitorVegetable,
                        Dairy                 = item.Dairy,
                        ProteinClassification = item.ProteinClassification
                    });
                }
            }
            return(foodandNutritions);
        }
Ejemplo n.º 3
0
        public void SupplyDetail_FoodDetailObjectNull_Test(int foodItemCount, String requestDate, string sellerName, double packingCharge)
        {
            FoodDetail   fooditem = null;
            SupplyDetail sd       = p.CreateSupplyDetail(foodItemCount, DateTime.Parse(requestDate), sellerName, packingCharge, fooditem);

            Assert.AreEqual(fooditem, sd);
        }
Ejemplo n.º 4
0
        public void SupplyDetail_ObjectNull_Null(int foodItemCount, String requestDate, string sellerName, double packingCharge)
        {
            fooditem = null;
            var supply = p.CreateSupplyDetail(foodItemCount, DateTime.Parse(requestDate), sellerName, packingCharge, fooditem);

            Assert.AreEqual(null, supply);
        }
Ejemplo n.º 5
0
        public void CreateSupplyDetail_NullFoodDetail_RaiseException(int foodItemCount, DateTime requestDate, string sellerName, double packingCharge, FoodDetail foodItem)
        {
            foodItem = new FoodDetail();
            var result = _program.CreateSupplyDetail(foodItemCount, requestDate, sellerName, packingCharge, foodItem);

            Assert.That(result, Is.EqualTo(null));
        }
Ejemplo n.º 6
0
        public void FoodDetail_ObjectCreation_Test(string name, int dishType, string expiryDate, double price)
        {
            FoodDetail food = p.CreateFoodDetail(name, dishType, DateTime.Parse(expiryDate), price);

            Assert.AreEqual(typeof(FoodDetail), food.GetType());
            Assert.AreEqual(name, food.Name);
        }
Ejemplo n.º 7
0
        public void SupplyDetail_DateLessThanCurrentDate_Exception(int foodItemCount, String requestDate, string sellerName, double packingCharge)
        {
            FoodDetail fooditem = p.CreateFoodDetail("Biriyani", 10, DateTime.Parse("2022/01/02"), 100.00);
            var        ex       = Assert.Throws <Exception>(() => p.CreateSupplyDetail(foodItemCount, DateTime.Parse(requestDate), sellerName, packingCharge, fooditem));

            Assert.That(ex.Message, Is.EqualTo("Incorrect food request date. Please provide valid value"));
        }
Ejemplo n.º 8
0
        public void TestForNull(int foodItemCount, string requestDate, string sellerName, double packingCharge)
        {
            DateTime     datetime   = DateTime.Parse(requestDate);
            FoodDetail   foodDetail = null;
            SupplyDetail supply     = program.CreateSupplyDetail(foodItemCount, datetime, sellerName, packingCharge, foodDetail);

            Assert.IsNull(supply);
        }
Ejemplo n.º 9
0
 public void Init()
 {
     p    = new Program();
     food = new FoodDetail()
     {
         Name = "Biryani", DishType = FoodDetail.Category.MainDish, Price = 150.00, ExpiryDate = DateTime.Now.AddYears(3)
     };
 }
Ejemplo n.º 10
0
 public void Init()
 {
     p    = new Program();
     Food = new FoodDetail()
     {
         Name = "Momos", DishType = FoodDetail.Category.MainDish, ExpiryDate = DateTime.Now.AddYears(5), Price = 100.0
     };
 }
Ejemplo n.º 11
0
        public string TestFoodDetails(string name, int dishtype, string expirydate, double price)
        {
            DateTime   temp       = DateTime.Parse(expirydate);
            FoodDetail foodDetail = program.CreateFoodDetail(name, dishtype, temp, price);
            string     result     = string.Format("{0},{1},{2},{3}", foodDetail.Name, foodDetail.DishType, foodDetail.ExpiryDate.ToShortDateString(), foodDetail.Price);

            return(result);
        }
Ejemplo n.º 12
0
        public ActionResult DeleteConfirmed(int id)
        {
            FoodDetail foodDetail = db.FoodDetails.Find(id);

            db.FoodDetails.Remove(foodDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void CreateFoodDetail_WhenCalled_ReturnFoodDetailObject(string name, int dishType, DateTime expiryDate, double price)
        {
            FoodDetail result = p.CreateFoodDetail(name, dishType, expiryDate, price);

            Assert.That(result.Name, Is.EqualTo(name));
            Assert.That(result.DishType, Is.EqualTo((FoodDetail.Category)dishType));
            Assert.That(result.ExpiryDate, Is.EqualTo(expiryDate));
            Assert.That(result.Price, Is.EqualTo(price));
        }
        public void showDetailFoodWindow(
            FoodTab foodTab,
            int foodId = Constant.ID_CREATE_NEW)
        {
            FoodDetail detail = new FoodDetail(
                foodTab,
                foodId);

            detail.ShowDialog();
        }
Ejemplo n.º 15
0
        public void FoodDetailObjCreateTest(string name, int dishType, DateTime expiryDate, double price)
        {
            FoodDetail food     = progObj.CreateFoodDetail(name, dishType, expiryDate, price);
            var        category = (FoodDetail.Category)dishType;

            Assert.That(food.Name, Is.EqualTo(name));
            Assert.That(food.DishType, Is.EqualTo(category));
            Assert.That(food.ExpiryDate, Is.EqualTo(expiryDate));
            Assert.That(food.Price, Is.EqualTo(price));
        }
Ejemplo n.º 16
0
        public void CreateFoodDetail_WhenCalled_ReturnFoodDetail(string name, int dishType, string expiryDate, double price)
        {
            FoodDetail f        = p.CreateFoodDetail(name, dishType, DateTime.Parse(expiryDate), price);
            var        category = (FoodDetail.Category)dishType;

            Assert.That(f.Name, Is.EqualTo(name));
            Assert.That(f.DishType, Is.EqualTo(category));
            Assert.That(f.ExpiryDate, Is.EqualTo(DateTime.Parse(expiryDate)));
            Assert.That(f.Price, Is.EqualTo(price));
        }
Ejemplo n.º 17
0
 public void Setup()
 {
     p        = new Program();
     foodItem = new FoodDetail()
     {
         Name       = "Salad",
         DishType   = (FoodDetail.Category) 3,
         ExpiryDate = new DateTime(2022, 01, 01),
         Price      = 30.50
     };
 }
Ejemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "FoodDetailID,FoodID,Calciumm,Calories,FatCalories,Carbohydrates,Cholesterol,Grease,Iron,Protein,Sodium,VitaminA,VitaminC")] FoodDetail foodDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(foodDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FoodID = new SelectList(db.Foods, "FoodID", "Name", foodDetail.FoodID);
     return(View(foodDetail));
 }
 public void Init()
 {
     program    = new Program();
     foodDetail = new FoodDetail()
     {
         Name       = "Biriyani",
         DishType   = (FoodDetail.Category) 1,
         ExpiryDate = new DateTime(2022, 8, 4),
         Price      = 100
     };
 }
Ejemplo n.º 20
0
        public void CreateSupplyDetail_RequestDateLessThanCurrentDate_RaiseException(int foodItemCount, DateTime requestDate, string sellerName, double packingCharge)
        {
            var foodItem = new FoodDetail()
            {
                Name       = "abc",
                DishType   = (FoodDetail.Category) 1,
                ExpiryDate = new DateTime(2021, 5, 8),
                Price      = 30.75
            };

            Assert.Throws <Exception>(() => _program.CreateSupplyDetail(foodItemCount, requestDate, sellerName, packingCharge, foodItem));
        }
Ejemplo n.º 21
0
        public void FoodCountLessThanEqualToZero(int foodItemCount, DateTime requestDate, string sellerName, double packingCharge)
        {
            var foodDetail = new FoodDetail()
            {
                Name       = "abc",
                DishType   = (FoodDetail.Category) 1,
                Price      = 150,
                ExpiryDate = new DateTime(2021, 4, 10),
            };

            Assert.Throws <Exception>(() => program.CreateSupplyDetail(foodItemCount, requestDate, sellerName, packingCharge, foodDetail));
        }
Ejemplo n.º 22
0
        // GET: FoodDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FoodDetail foodDetail = db.FoodDetails.Find(id);

            if (foodDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(foodDetail));
        }
Ejemplo n.º 23
0
        public void SupplyDetailObjectCreatedTest(int foodItemCount, DateTime requestDate, string sellerName, double packingCharge)
        {
            var foodDetail = new FoodDetail()
            {
                Name       = "abc",
                DishType   = (FoodDetail.Category) 1,
                Price      = 150,
                ExpiryDate = new DateTime(2021, 4, 10),
            };

            var result = program.CreateSupplyDetail(foodItemCount, requestDate, sellerName, packingCharge, foodDetail);

            Assert.That(result, Is.TypeOf <SupplyDetail>());
        }
Ejemplo n.º 24
0
        public void CreateSupplyDetail_WhenCalled_ReturnSupplyDetail(int foodItemCount, DateTime requestDate, string sellerName, double packingCharge)
        {
            var foodItem = new FoodDetail()
            {
                Name       = "abc",
                DishType   = (FoodDetail.Category) 1,
                ExpiryDate = new DateTime(2021, 6, 9),
                Price      = 30.75
            };

            var result = _program.CreateSupplyDetail(foodItemCount, requestDate, sellerName, packingCharge, foodItem);

            Assert.That(result, Is.TypeOf <SupplyDetail>());
        }
Ejemplo n.º 25
0
        // GET: FoodDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FoodDetail foodDetail = db.FoodDetails.Find(id);

            if (foodDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FoodID = new SelectList(db.Foods, "FoodID", "Name", foodDetail.FoodID);
            return(View(foodDetail));
        }
Ejemplo n.º 26
0
        public void CreateFoodDetail_WhenCreated_ReturnObject(string name, int category, double price, DateTime expDate)
        {
            FoodDetail m = null;

            try
            {
                m = p.CreateFoodDetail(name, category, expDate, price);

                Assert.IsNotNull(m);
            }
            catch (Exception)
            {
                Assert.Fail("Food details Object not created successfully");
            }
        }
Ejemplo n.º 27
0
            public void TestFoodObjectCreation(string FoodName, int Category, double Price, DateTime ExpDate)
            {
                FoodDetail F = null;

                try
                {
                    F = p.CreateFoodDetail(FoodName, Category, ExpDate, Price);

                    Assert.IsNotNull(F);
                }
                catch (Exception)
                {
                    Assert.Fail("FoodDetail Object not created successfully");
                }
            }
Ejemplo n.º 28
0
        public string TestSupplyDetails(int foodItemCount, string requestdate, string sellerName, double packingCharge)
        {
            DateTime datetime   = DateTime.Parse(requestdate);
            var      foodDetail = new FoodDetail()
            {
                Name       = "Mathew",
                DishType   = (FoodDetail.Category) 1,
                ExpiryDate = DateTime.Parse("2020-03-30"),
                Price      = 30
            };
            SupplyDetail supplyDetail = program.CreateSupplyDetail(foodItemCount, datetime, sellerName, packingCharge, foodDetail);
            String       result       = string.Format("{0},{1},{2},{3}", supplyDetail.SellerName, supplyDetail.RequestDate.ToShortDateString(), supplyDetail.Count, supplyDetail.TotalCost);


            return(result);
        }
Ejemplo n.º 29
0
 public OrderPage()
 {
     BindingContext = new Fabrirkam_Food.MenuPageViewModel();
     InitializeComponent();
     this.getFoodList();
     FoodList.ItemsSource   = _foodList;
     FoodList.ItemSelected += (sender, e) =>
     {
         if (e.SelectedItem == null)
         {
             return;
         }
         FoodDetail fd = (FoodDetail)e.SelectedItem;
         App.RootPage.Detail = new NavigationPage(new OrderFoodPage(fd.name, fd.price));
         App.MenuIsPresented = false;
     };
 }
Ejemplo n.º 30
0
        public async Task AddDetail(int foodId, EFoodDetailType type, string transactionHash, int userID)
        {
            var foodDetail = new FoodDetail()
            {
                TransactionHash = transactionHash,
                FoodId          = foodId,
                CreateById      = userID
            };

            switch (type)
            {
            case EFoodDetailType.CREATE:
                foodDetail.TypeId = FoodDetailTypeDataConstant.CREATE_NEW_ID;
                break;

            case EFoodDetailType.FEEDING:
                foodDetail.TypeId = FoodDetailTypeDataConstant.ADD_FEEDING_ID;
                break;

            case EFoodDetailType.VACCINATION:
                foodDetail.TypeId = FoodDetailTypeDataConstant.ADD_VACCINATION_ID;
                break;

            case EFoodDetailType.VERIFY:
                foodDetail.TypeId = FoodDetailTypeDataConstant.ADD_VERIFY_ID;
                break;

            case EFoodDetailType.PROVIDER:
                foodDetail.TypeId = FoodDetailTypeDataConstant.ADD_PROVIDER_ID;
                break;

            case EFoodDetailType.TREATMENT:
                foodDetail.TypeId = FoodDetailTypeDataConstant.ADD_TREATMENT_ID;
                break;

            case EFoodDetailType.PACKAGING:
                foodDetail.TypeId = FoodDetailTypeDataConstant.ADD_PACKAGING_ID;
                break;

            default: break;
            }

            await _foodDetailRepository.InsertAsync(foodDetail);
        }