예제 #1
0
        internal string GetIngredientInGrams(ShoppingFood food, int currUnit)
        {
            MeasurementUnitsConvert convert = BusinessFacade.Instance.GetMeasurementUnitsConvertList().SingleOrDefault(mc => mc.FoodId == food.FoodId &&
                                                                                                                       mc.FromUnitId == currUnit &&
                                                                                                                       mc.ToUnitId == (int)AppConstants.GRAMM_UNIT_ID);

            string result = string.Empty;

            if (convert != null)
            {
                decimal unitQuantity = (convert.ToQuantity / convert.FromQuantity) * food.Quantity;

                result = string.Format("{0} {1}", BusinessFacade.Instance.GetNumberWithFreg(unitQuantity), "גרם");
            }

            return(result);
        }
예제 #2
0
    protected void rptFoods_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem rptItem  = e.Item as RepeaterItem;
        ShoppingFood foodItem = (ShoppingFood)rptItem.DataItem;

        if (foodItem == null)
        {
            return;
        }

        Label food = rptItem.FindControl("lblFood") as Label;

        if (foodItem.CalculateUnitId == (int)AppConstants.GRAMM_UNIT_ID)
        {
            food.Text = string.Format("{0} {1}", foodItem.Display, foodItem.FoodName);
        }
        else
        {
            string grams = BusinessFacade.Instance.GetIngredientInGrams(foodItem, foodItem.CalculateUnitId);

            if (grams != string.Empty)
            {
                food.Text = string.Format("{0} / {1} {2}", foodItem.Display, grams, foodItem.FoodName);
            }
            else
            {
                food.Text = string.Format("{0} {1}", foodItem.Display, foodItem.FoodName);
            }
        }

        if (foodItem.Picture != null && foodItem.PrintPicture)
        {
            Image foodImage = rptItem.FindControl("imgFood") as Image;
            foodImage.Visible  = true;
            foodImage.ImageUrl = "http://www.mybuylist.com/ShowPicture.ashx?FoodId=" + foodItem.FoodId;
        }
    }
예제 #3
0
 public string GetIngredientInGrams(ShoppingFood food, int currUnit)
 {
     return(new ShoppingsListManager().GetIngredientInGrams(food, currUnit));
 }