public ActionResult Save(int? FishID, string FishName, int price, int shadow, int rarity, string saying)
        {
            NewLeafContext nlc = new NewLeafContext();
            Fish fish = new Fish();
            if (FishID.HasValue)
            {
                fish.FishID = (int)FishID;
                fish = nlc.Fishes.Where(x => x.FishID == fish.FishID).FirstOrDefault();
            }
            else
            {
                fish.FishID = nlc.Fishes.Max(x => x.FishID) + 1;
                nlc.Fishes.Add(fish);
            }

            fish.FishName = FishName;
            fish.Price = price;
            fish.ShadowSizeID = shadow;
            fish.FishRarityID = rarity;
            fish.CheesySaying = saying;

            nlc.SaveChanges();

            return View();
        }
        //
        // GET: /Fish/
        public FishVM Get(string fishName)
        {
            NewLeafContext nlc = new NewLeafContext();
            Fish seaBass = nlc.Fishes.Include("FishTimes").Include("ShadowSize").Include("Rarity").Include("FishTimes.FishLocation").FirstOrDefault(f => f.FishName == fishName);

            return seaBass;
        }
        //
        // GET: /EditFish/
        public ActionResult Index(int? fish)
        {
            NewLeafContext nlc = new NewLeafContext();
            if (fish.HasValue)
            {
                Fish editFish = nlc.Fishes.Include("ShadowSize").Include("Rarity").Where(x => x.FishID == (int)fish).FirstOrDefault();

                SelectList shadow;
                SelectList rarity;
                if (editFish != null)
                {
                    ViewData["FishID"] = editFish.FishID;
                    shadow = new SelectList(nlc.ShadowSize, "ShadowSizeID", "ShadowSizeText", editFish.ShadowSizeID);
                    rarity = new SelectList(nlc.FishRarity, "FishRarityID", "Rarity", editFish.FishRarityID);
                    ViewData["FishName"] = editFish.FishName;
                    ViewData["Price"] = editFish.Price;
                    ViewData["Saying"] = editFish.CheesySaying;
                }
                else
                {
                    shadow = new SelectList(nlc.ShadowSize, "ShadowSizeID", "ShadowSizeText");
                    rarity = new SelectList(nlc.FishRarity, "FishRarityID", "Rarity");
                }
                ViewData["Shadow"] = shadow;
                ViewData["Rarity"] = rarity;
            }
            else
            {
                ViewData["Shadow"] = new SelectList(nlc.ShadowSize, "ShadowSizeID", "ShadowSizeText");
                ViewData["Rarity"] = new SelectList(nlc.FishRarity, "FishRarityID", "Rarity");
            }
            return View();
        }
 public List<FishVM> Get()
 {
     NewLeafContext nlc = new NewLeafContext();
     nlc.Configuration.ProxyCreationEnabled = false;
     var fishes = nlc.Fishes.Include("FishTimes").Include("ShadowSize").Include("FishTimes.FishLocation").Include("Rarity").ToList();
     List<FishVM> fishList = new List<FishVM>();
     foreach (Fish fish in fishes)
     {
         fishList.Add(fish);
     }
     return fishList;
 }
        public List<FishVM> GetCurrentFish(long ticks, string includeTropical = "N")
        {
            NewLeafContext nlc = new NewLeafContext();
            nlc.Configuration.ProxyCreationEnabled = false;

            DateTime currentDate = new DateTime(ticks);

            List<FishVM> fishes = new List<FishVM>();

            DateTime datePart = new DateTime(2000, currentDate.Month, currentDate.Day);

            DateTime timePart = new DateTime(2000, 1, 1, currentDate.Hour, currentDate.Minute, currentDate.Second);

            List<FishTime> fishTimes;

            if (includeTropical == "N")
            {
                fishTimes = nlc.FishTimes.Include("Fish").Include("FishLocation").Include("Fish.Rarity").Include("Fish.ShadowSize")
                .Where(ft => ft.FishLocation.LocationName != "Tropical Island" && (
                    ( ft.DateBegin < ft.DateEnd && ( ft.DateBegin <= datePart && ft.DateEnd >= datePart ) && (
                        ( ft.TimeBegin < ft.TimeEnd && ( ft.TimeBegin <= timePart && ft.TimeEnd > timePart ) ) ||
                        ( ft.TimeBegin > ft.TimeEnd && ( ft.TimeBegin <= timePart || ft.TimeEnd > timePart ) )
                    ) ) ||
                    ( ft.DateBegin > ft.DateEnd && ( ft.DateBegin <= datePart || ft.DateEnd >= datePart ) && (
                        ( ft.TimeBegin < ft.TimeEnd && ( ft.TimeBegin <= timePart && ft.TimeEnd > timePart ) ) ||
                        ( ft.TimeBegin > ft.TimeEnd && ( ft.TimeBegin <= timePart || ft.TimeEnd > timePart ) )
                    ) )
                )).OrderBy(ft => ft.Fish.FishName).ToList();
            }
            else
            {
                fishTimes = nlc.FishTimes.Include("Fish").Include("FishLocation")
                .Where(ft => ft.FishLocation.LocationName == "Tropical Island" && ((ft.DateBegin < ft.DateEnd && ft.DateBegin <= datePart && ft.DateEnd >= datePart && ((ft.TimeBegin < ft.TimeEnd && (ft.TimeBegin <= timePart && ft.TimeEnd > timePart)) || (ft.TimeBegin > ft.TimeEnd && (ft.TimeBegin <= timePart || ft.TimeEnd > timePart)))) || (ft.DateBegin > ft.DateEnd && ft.DateBegin <= datePart || ft.DateEnd >= datePart && ((ft.TimeBegin < ft.TimeEnd && (ft.TimeBegin <= timePart && ft.TimeEnd > timePart)) || (ft.TimeBegin > ft.TimeEnd && (ft.TimeBegin <= timePart || ft.TimeEnd > timePart)))))).OrderBy(ft => ft.Fish.FishName).ToList();
            }

            foreach (FishTime ft in fishTimes)
            {
                if (!fishes.Any(f => f.FishName == ft.Fish.FishName))
                {
                    var fish = ft.Fish;
                    //fish.FishTimes.Add(ft);
                    fishes.Add(fish);
                }
            }

            return fishes;
        }