Exemple #1
0
        public void SaveCuisine(Rootobject cuisine)
        {
            var type = new FoodDrinkType
            {
                CategoryId = 19,
                Name       = "Türk ve Dünya Mutfağı"
            };

            UnitOfWork.CurrentSession.FoodDrinkTypes.Add(type);
            foreach (var item in cuisine.response.venues)
            {
                var model = new FoodAndDrink
                {
                    TypeId = type.Id,
                    Name   = item.name ?? "Türk Mutfağı",
                    Lat    = item.location.lat,
                    Long   = item.location.lng,
                    Adress = item.location.address ?? "",
                    Phone  = item.contact == null ? "" : item.contact.phone,
                    Url    = item.url ?? "",
                    IconId = 6
                };
                UnitOfWork.CurrentSession.FoodAndDrinks.Add(model);
            }
            UnitOfWork.CurrentSession.SaveChanges();
        }
Exemple #2
0
        public void SaveMarket(Rootobject market)
        {
            var type = new FoodDrinkType
            {
                CategoryId = 1,
                Name       = "Market"
            };

            UnitOfWork.CurrentSession.FoodDrinkTypes.Add(type);
            foreach (var item in market.response.venues)
            {
                var data = new FoodAndDrink
                {
                    TypeId = type.Id,
                    Name   = item.name ?? "Market",
                    Lat    = item.location.lat,
                    Long   = item.location.lng,
                    Adress = item.location.address ?? "",
                    Phone  = item.contact == null ? "" : item.contact.phone,
                    Url    = item.url == null ? "" : item.url
                             //Description = item.menu.label,
                };
                UnitOfWork.CurrentSession.FoodAndDrinks.Add(data);
            }
            var model = UnitOfWork.CurrentSession.SaveChanges();
        }
Exemple #3
0
        public void SaveBreakfast(Rootobject breakfast)
        {
            var type = new FoodDrinkType
            {
                CategoryId = 19,
                Name       = "Kahvaltı"
            };

            UnitOfWork.CurrentSession.FoodDrinkTypes.Add(type);
            foreach (var item in breakfast.response.venues)
            {
                var model = new FoodAndDrink
                {
                    TypeId = type.Id,
                    Name   = item.name ?? "Kahvaltı",
                    Lat    = item.location.lat,
                    Long   = item.location.lng,
                    Adress = item.location.address ?? "",
                    Phone  = item.contact == null ? "" : item.contact.phone,
                    Url    = item.url == null ? "" : item.url,
                    IconId = 10
                };
                UnitOfWork.CurrentSession.FoodAndDrinks.Add(model);
            }
            UnitOfWork.CurrentSession.SaveChanges();
        }
        public ActionResult GetFoodAndDrinkByID(int id)
        {
            FoodAndDrink fd = info.GetFoodAndDrinkByID(id);
            var          a  = fd.GetType().ToString();

            return(Json(new { FDID = fd.FDID, Name = fd.Name, UnitPrice = fd.UnitPrice }, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public void SaveRestaurant(Rootobject restaurant)
        {
            var type = new FoodDrinkType
            {
                CategoryId = 1,
                Name       = "Restaurant"
            };

            UnitOfWork.CurrentSession.FoodDrinkTypes.Add(type);
            foreach (var item in restaurant.response.venues)
            {
                var model = new FoodAndDrink
                {
                    TypeId = type.Id,
                    Name   = item.name ?? "Restaurant",
                    Lat    = item.location.lat,
                    Long   = item.location.lng,
                    Adress = item.location.address ?? "",
                    Phone  = item.contact == null ? "" : item.contact.phone,
                    Url    = item.url == null ? "" : item.url
                };
                UnitOfWork.CurrentSession.FoodAndDrinks.Add(model);
            }
            UnitOfWork.CurrentSession.SaveChanges();
        }
        public ActionResult DoEditFoodAndDrink(int FDID, string Name, string Desc,
                                               HttpPostedFileBase ImagePath, string Size, string Type, double UnitPrice, string Currency)
        {
            var    Image               = ImagePath;
            string fileName            = ImagePath.FileName;
            var    path                = Path.Combine(Server.MapPath("/Assets/resource/img/recype"), fileName);
            string fileNameNoExtension = Path.GetFileNameWithoutExtension(fileName);
            string extension           = Path.GetExtension(fileName);
            int    temp                = 1;

            while (System.IO.File.Exists(path))
            {
                fileName = fileNameNoExtension + "Copy(" + temp + ")" + extension;
                path     = Path.Combine(Server.MapPath("/Assets/resource/img/recype"), fileName);
                temp++;
            }
            ImagePath.SaveAs(path);
            string       imagePath = "/Assets/resource/img/recype/" + fileName;
            FoodAndDrink fd        = new FoodAndDrink();

            fd.FDID      = FDID;
            fd.Name      = Name;
            fd.Desc      = Desc;
            fd.ImagePath = imagePath;
            fd.Size      = Size;
            fd.Type      = Type;
            fd.UnitPrice = UnitPrice;
            fd.Currency  = Currency;
            bool result = info.EditFoodAndDrink(fd);

            return(RedirectToAction("GetAllFoodAndDrink", "Batender"));
        }
Exemple #7
0
        public void SaveClub(Rootobject club)
        {
            var type = new FoodDrinkType
            {
                CategoryId = 19,
                Name       = "Gece Kulübü",
            };

            UnitOfWork.CurrentSession.FoodDrinkTypes.Add(type);
            foreach (var item in club.response.venues)
            {
                var model = new FoodAndDrink
                {
                    TypeId = type.Id,
                    Name   = item.name ?? "Gece Kulübü",
                    Lat    = item.location.lat,
                    Long   = item.location.lng,
                    Adress = item.location.address ?? "",
                    Phone  = item.contact == null ? "" : item.contact.phone,
                    Url    = item.url ?? "",
                    IconId = 9
                };
                UnitOfWork.CurrentSession.FoodAndDrinks.Add(model);
            }
            UnitOfWork.CurrentSession.SaveChanges();
        }
Exemple #8
0
 public bool DeleteFoodAndDrinkByFDID(int FDID)
 {
     try
     {
         FoodAndDrink fd = GetFoodAndDrinkByID(FDID);
         context.FoodAndDrinks.DeleteOnSubmit(fd);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception("Error DeleteFoodAndDrinkByFDID" + ex.Message);
     }
 }
Exemple #9
0
        public void SaveCafe(Rootobject cafe)
        {
            var cat = new Category
            {
                Name  = "Yeme İçme",
                Color = "#ff3748"
            };

            UnitOfWork.CurrentSession.Categories.Add(cat);

            var type = new FoodDrinkType
            {
                CategoryId = cat.Id,
                Name       = "Kafe"
            };

            UnitOfWork.CurrentSession.FoodDrinkTypes.Add(type);
            int icon     = 1;
            var IconName = UnitOfWork.CurrentSession.Icons.FirstOrDefault(x => x.IconName == "cafe");

            if (IconName != null)
            {
                icon = IconName.Id;
            }

            foreach (var item in cafe.response.venues)
            {
                var data = new FoodAndDrink
                {
                    TypeId = type.Id,
                    Name   = item.name ?? "Cafe",
                    Lat    = item.location.lat,
                    Long   = item.location.lng,
                    Adress = item.location.address ?? "",
                    Phone  = item.contact == null ? "" : item.contact.phone,
                    Url    = item.url ?? "",
                    IconId = icon

                             //Description = item.menu.label,
                };
                UnitOfWork.CurrentSession.FoodAndDrinks.Add(data);
            }
            var model = UnitOfWork.CurrentSession.SaveChanges();
        }
Exemple #10
0
        public bool EditFoodAndDrink(FoodAndDrink foodAndDrink)
        {
            try
            {
                FoodAndDrink fd = context.FoodAndDrinks.FirstOrDefault(f => f.FDID == foodAndDrink.FDID);
                fd.Name      = foodAndDrink.Name;
                fd.Desc      = foodAndDrink.Desc;
                fd.ImagePath = foodAndDrink.ImagePath;
                fd.Size      = foodAndDrink.Size;
                fd.Type      = foodAndDrink.Type;
                fd.UnitPrice = foodAndDrink.UnitPrice;
                fd.Currency  = foodAndDrink.Currency;
                context.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Error EditFoodAndDrink" + ex.Message);
            }
        }
        public bool CreateFoodAndDrinkItem(FoodAndDrinkCreate item)
        {
            var newItem =
                new FoodAndDrink()
            {
                Id              = _userid.ToString(),
                OwnerId         = _userid,
                Item            = item.Item,
                IsFood          = item.IsFood,
                IsDrink         = item.IsDrink,
                CarbsPerServing = item.CarbsPerServing,
                ServingSize     = item.ServingSize,
                FastActingCarb  = item.FastActingCarb,
                Favorite        = item.Favorite,
                CreatedUtc      = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.FoodAndDrinks.Add(newItem);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #12
0
        public bool InsertFoodAndDrink(string Name, string Desc,
                                       string ImagePath, string Size, string Type, double UnitPrice, string Currency)
        {
            int FDID = GetLastID() + 1;

            try
            {
                FoodAndDrink fd = new FoodAndDrink();
                fd.Name      = Name;
                fd.Desc      = Desc;
                fd.ImagePath = ImagePath;
                fd.Size      = Size;
                fd.Type      = Type;
                fd.UnitPrice = UnitPrice;
                fd.Currency  = Currency;
                context.FoodAndDrinks.InsertOnSubmit(fd);
                context.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("Error Insert FoodAndDrink " + ex.Message);
            }
        }
        private static void UseGameObject(List <GameObject> gameObjects)
        {
            string headerText      = "";
            string hitHealthText   = "";
            int    hitHealthPoints = 0;

            if (gameObjects != null)
            {
                //
                // set header and point type text
                //
                if (gameObjects[0] is Weapon)
                {
                    headerText    = "Use Weapon";
                    hitHealthText = "Hit points: ";
                }
                else if (gameObjects[0] is FoodAndDrink)
                {
                    headerText    = "Use Food and Drink";
                    hitHealthText = "Health points: ";
                }
                else
                {
                    headerText    = "Unknown Game Object Type";
                    hitHealthText = "Unknown point type: ";
                }

                //
                // display header
                //
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine("\t\t" + headerText);
                Console.WriteLine();


                foreach (GameObject gameObject in gameObjects)
                {
                    //
                    // set hit and health points
                    //
                    if (gameObjects[0] is Weapon)
                    {
                        Weapon weaponGameObject = (Weapon)gameObject;
                        hitHealthPoints = weaponGameObject.HitPoints;
                    }
                    else if (gameObjects[0] is FoodAndDrink)
                    {
                        FoodAndDrink foodAndDrinkGameObject = (FoodAndDrink)gameObject;
                        hitHealthPoints = foodAndDrinkGameObject.HealthPoints;
                    }
                    else
                    {
                        hitHealthPoints = 0;
                    }

                    //
                    // display game object use info
                    //
                    Console.WriteLine();
                    Console.WriteLine("\t" + gameObject.Message());
                    Console.WriteLine("\t" + gameObject.Use());
                    Console.WriteLine("\t" + hitHealthText + hitHealthPoints);
                }
            }
            else
            {
                Console.WriteLine("It appears there are no game objects to use.");
            }

            Console.WriteLine();
            Console.WriteLine("\t\tPress any key to continue.");
            Console.ReadKey();
        }
        public ActionResult DeleteFoodAndDrink(int FDID)
        {
            FoodAndDrink fd = info.GetFoodAndDrinkByFDID(FDID);

            return(View(fd));
        }
        private static void DisplayGameObjects(List <GameObject> gameObjects)
        {
            string headerText      = "";
            string hitHealthText   = "";
            int    hitHealthPoints = 0;

            //
            // set header and point type text
            //
            if (gameObjects != null)
            {
                //
                // set header and point type text
                //
                if (gameObjects[0] is Weapon)
                {
                    headerText    = "Use Weapon";
                    hitHealthText = "Hit Points";
                }
                else if (gameObjects[0] is FoodAndDrink)
                {
                    headerText    = "Use Food and Drink";
                    hitHealthText = "Health Points";
                }
                else
                {
                    headerText    = "Unknown Game Object Type";
                    hitHealthText = "Unknown";
                }

                //
                // display header
                //
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine("\t\t" + headerText);
                Console.WriteLine();


                Console.WriteLine(
                    "\t" +
                    "Id".PadLeft(5) +
                    "Name".PadLeft(25) +
                    "Consumable".PadLeft(15) +
                    hitHealthText.PadLeft(15)
                    );
                Console.WriteLine(
                    "\t" +
                    "----".PadLeft(5) +
                    "--------------".PadLeft(25) +
                    "--------------".PadLeft(15) +
                    "--------------".PadLeft(15)
                    );

                foreach (GameObject gameObject in gameObjects)
                {
                    //
                    // set hit and health points
                    //
                    if (gameObjects[0] is Weapon)
                    {
                        Weapon weaponGameObject = (Weapon)gameObject;
                        hitHealthPoints = weaponGameObject.HitPoints;
                    }
                    else if (gameObjects[0] is FoodAndDrink)
                    {
                        FoodAndDrink foodAndDrinkGameObject = (FoodAndDrink)gameObject;
                        hitHealthPoints = foodAndDrinkGameObject.HealthPoints;
                    }
                    else
                    {
                        hitHealthPoints = 0;
                    }

                    //
                    // display table info
                    //
                    Console.WriteLine(
                        "\t" +
                        gameObject.Id.ToString().PadLeft(5) +
                        gameObject.Name.PadLeft(25) +
                        (gameObject.Consumable ? "Yes" : "No").PadLeft(15) +
                        hitHealthPoints.ToString().PadLeft(15)
                        );
                }
            }
            else
            {
                Console.WriteLine("It appears there are no game objects to display.");
            }

            Console.WriteLine();
            Console.WriteLine("\t\tPress any key to continue.");
            Console.ReadKey();
        }
 public bool EditFoodAndDrink(FoodAndDrink foodAndDrink)
 {
     return(this._foodAndDrinkDAO.EditFoodAndDrink(foodAndDrink));
 }
Exemple #17
0
 public OrcService()
 {
     orcList     = new List <Orc>();
     whatOrcEats = new FoodAndDrink();
 }