Пример #1
0
        public ActionResult ListSeed()
        {
            #region
            Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
            if (memberData == null)
                return RedirectToAction("Default", "Member");
            SeedAction objSeed = new SeedAction();
            LocationAction objLocation = new LocationAction();
            IList<Location> locData = objLocation.GetLocationByMemberId(memberData.id.ToString());

            List<Seed> currentSeedList = new List<Seed>();

            if (locData != null)
            {
                foreach (Location tempLocation in locData)
                {
                    IList<Seed> seedList = objSeed.GetSeedByLocationId(tempLocation.id.ToString());
                    foreach (Seed seedData in seedList)
                    {
                        if (seedData.status == SystemStatements.STATUS_NEW || seedData.status == SystemStatements.STATUS_GROWING)
                            currentSeedList.Add(seedData);
                    }
                }
            }

            ViewData["ListSeed"] = currentSeedList;

            return View();
            #endregion
        }
        /// <summary>
        /// Method to get all seeds by member location.
        /// </summary>
        /// <param name="MemberId"></param>
        /// <returns></returns>
        public string GetSeedByMemberLocation(string MemberId)
        {
            #region
            SeedAction objSeed = new SeedAction();

            LocationAction objLocation = new LocationAction();
            string returnList = "";

            IList<Location> locData = objLocation.GetLocationByMemberId(MemberId);
            Location memberLocation = objLocation.GetMemberLocationById(MemberId);
            if (memberLocation == null)
            {
                memberLocation = new Location();
                memberLocation.localLong = -112.0740373;
                memberLocation.localLat = 33.4483771;
            }

            IList<Seed> tempList1 = objSeed.GetSeedsByUser(MemberId).ToList();
            IList<Seed> tempList2 = objSeed.GetAllSeedsCommentedByMe(MemberId);
            var tempList3 = tempList1.Union(tempList2);
            IList<Seed> listSeed = (from gs in tempList3 select gs).OrderByDescending(x => x.createDate).Distinct().ToList();
            List<Seed> currentSeedList = new List<Seed>();

            if (locData == null)
            {
                returnList = "33.4483771,-112.0740373";
            }
            else
            {
                foreach (Location tempLocation in locData)
                {
                    IList<Seed> seedList = objSeed.GetSeedByLocationId(tempLocation.id.ToString());
                    foreach (Seed seedData in seedList)
                    {
                        returnList += "," + tempLocation.localLat.ToString() + "," + tempLocation.localLong.ToString();
                    }
                }

                if (returnList.Length == 0)
                {
                    returnList = "33.4483771,-112.0740373";
                }
                else
                {
                    returnList = returnList.Substring(1);
                }
            }
            return returnList;
            #endregion
        }