Esempio n. 1
0
        // post Review in food
        public string PostReview(string FID, string CID, string Rating, string comment = "")
        {
            System.Int64 FOODID = System.Convert.ToInt64(FID);
            System.Int64 CusID  = System.Convert.ToInt64(CID);

            FoodReview ObjFoodReview = FoodReview.List.Find(x => x.FID == FOODID && x.CID == CusID);

            if (ObjFoodReview != null)
            {
                ObjFoodReview.Rating  = System.Convert.ToInt32(Rating);
                ObjFoodReview.Comment = ObjFoodReview.Comment + " " + comment;
                if (ObjFoodReview.Update() == 0)
                {
                    return("Error in Update Revivew");
                }
            }
            else
            {
                ObjFoodReview = new FoodReview()
                {
                    FID     = FOODID,
                    CID     = CusID,
                    Rating  = System.Convert.ToInt32(Rating),
                    Comment = comment
                };
                if (ObjFoodReview.Insert() == 0)
                {
                    return("Error in PostRating");
                }
            }

            // update Rating of food
            int RN1 = FoodReview.List.FindAll(x => x.FID == FOODID && x.Rating == 1).Count();
            int RN2 = FoodReview.List.FindAll(x => x.FID == FOODID && x.Rating == 2).Count();
            int RN3 = FoodReview.List.FindAll(x => x.FID == FOODID && x.Rating == 3).Count();
            int RN4 = FoodReview.List.FindAll(x => x.FID == FOODID && x.Rating == 4).Count();
            int RN5 = FoodReview.List.FindAll(x => x.FID == FOODID && x.Rating == 5).Count();

            Food   ObjFood    = Food.List.Find(x => x.FID == FOODID);
            double FoodRating = (RN1 + RN2 + RN3 + RN4 + RN5) / 5;

            ObjFood.Rating = FoodRating.ToString("0.00");
            //int RN1_1 = -RN1;
            //int RN2_1 = -2 * (RN2);
            //int RN4_1 = RN4;
            //int RN5_1 = 2 * RN5;
            /// ObjFood.Rating = (System.Convert.ToDouble((RN1_1 + RN2_1 + RN4_1 + RN5_1) / (RN1 + RN2 + RN3 + RN4 + RN5))).ToString();
            if (ObjFood.Save() != 0)
            {
                return("YES");
            }
            return("ERROR IN RATING");
        }
Esempio n. 2
0
        // Item details
        public App_Review GetReview(string FID, int CID)
        {
            List <FoodReview> ListFoodReview = FoodReview.List.FindAll(x => x.FID == System.Convert.ToInt64(FID));
            FoodReview        OwnRatingObj   = ListFoodReview.Find(x => x.CID == CID);
            App_Review        App_Review     = new App_Review();

            App_Review.NumberOfRatingCount = ListFoodReview.Count;
            App_Review.Rating         = ListFoodReview.Sum(x => x.Rating) / 5;
            App_Review.OwnRating      = (OwnRatingObj != null) ? OwnRatingObj.Rating : 0;
            App_Review.NoOfOrderCount = OrderItem.List.FindAll(x => x.FID == System.Convert.ToInt64(FID)).Count;
            return(App_Review);
        }
Esempio n. 3
0
        // Get List Mess Item
        public List <App_MessItemList> GetMessItem(string SearchTerm = "", string CID = "", string FoodType = "", string UID = "", string MealsType = "")
        {
            List <App_MessItemList> ListMessItemList = new List <App_MessItemList>();

            List <Food> ListFood = Food.List;

            List <Cart> ListCart = Cart.List.FindAll(x => x.CID == System.Convert.ToInt64(UID));


            if (!SearchTerm.Equals(""))
            {
                ListFood = ListFood.FindAll(x => x.Food_Name.ToLower().Contains(SearchTerm.ToLower()));
            }
            if (!CID.Equals(""))
            {
                ListFood = ListFood.FindAll(x => x.Category_ID.ToString() == CID);
            }
            if (!FoodType.Equals(""))
            {
                ListFood = ListFood.FindAll(x => x.FoodType.Contains(FoodType));
            }
            if (!MealsType.Equals(""))
            {
                ListFood = ListFood.FindAll(x => x.MealsType.Contains(MealsType));
            }
            List <FoodReview> FoodReviewList = FoodReview.List.FindAll(x => x.CID == System.Int64.Parse(UID));

            foreach (Food ObjFood in ListFood)
            {
                Mess             ObjMess = Mess.List.Find(x => x.MID == ObjFood.MID);
                App_MessItemList TmpObj  = new App_MessItemList();
                //mess details
                TmpObj.MID      = ObjMess.MID.ToString();
                TmpObj.MessName = ObjMess.Mess_Name;
                //food details
                TmpObj.FID             = ObjFood.FID.ToString();
                TmpObj.ItemImage       = Host + ObjFood.Food_Image;
                TmpObj.ItemName        = ObjFood.Food_Name;
                TmpObj.ItemQuntity     = ObjFood.Qty;
                TmpObj.ItemPrice       = ObjFood.Price.ToString();
                TmpObj.ItemDescription = ObjFood.Description;
                TmpObj.Rating          = ObjFood.Rating;
                TmpObj.FoodType        = ObjFood.FoodType;
                TmpObj.MealsType       = MealsType;
                Cart ObjCart = ListCart.Find(x => x.FID == ObjFood.FID && x.MealType == MealsType);
                if (ObjCart != null)
                {
                    TmpObj.Count = ObjCart.Count.ToString();
                }
                else
                {
                    TmpObj.Count = "0";
                }

                FoodReview FoodNoteInfoObj = FoodReviewList.Find(x => x.FID == ObjFood.FID);
                if (FoodNoteInfoObj != null)
                {
                    TmpObj.NoteInfo = FoodNoteInfoObj.Comment;
                }
                else
                {
                    TmpObj.NoteInfo = "";
                }
                ListMessItemList.Add(TmpObj);
            }

            return(ListMessItemList);
        }