private void FixupSeed(Seed previousValue)
        {
            if (previousValue != null && previousValue.MemberReplySeeds.Contains(this))
            {
                previousValue.MemberReplySeeds.Remove(this);
            }

            if (Seed != null)
            {
                if (!Seed.MemberReplySeeds.Contains(this))
                {
                    Seed.MemberReplySeeds.Add(this);
                }
                if (seedID != Seed.id)
                {
                    seedID = Seed.id;
                }
            }
            else if (!_settingFK)
            {
                seedID = null;
            }
        }
Beispiel #2
0
        private void FixupSeed(Seed previousValue)
        {
            if (previousValue != null && previousValue.Media.Contains(this))
            {
                previousValue.Media.Remove(this);
            }

            if (Seed != null)
            {
                if (!Seed.Media.Contains(this))
                {
                    Seed.Media.Add(this);
                }
                if (seedId != Seed.id)
                {
                    seedId = Seed.id;
                }
            }
            else if (!_settingFK)
            {
                seedId = null;
            }
        }
        /// <summary>
        /// This method is used to Add new Seeds.
        /// </summary>
        /// <param name="SeedName"></param>
        /// <param name="Description"></param>
        /// <param name="CityName"></param>
        /// <param name="Street"></param>
        /// <param name="RegionCode"></param>
        /// <param name="LatLong"></param>
        /// <param name="ZipCode"></param>
        /// <param name="ownerId"></param>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public string AddSeedData(string SeedName, string Description, string CityName, string Street, string RegionCode, string Lat, string Lng, string ZipCode, string ownerId, string tagName, string imageName, string categoryNames)
        {
            bool actionCompleted = false;
            Seed seedData = null;
            string imagePath = imageName;
            string result = "Error while seed planting.";
            try
            {
                SeedAction objSeed = new SeedAction();

                Seed objSeedEntity = new Seed();
                Member memberData = new Member();
                Tag objTagEntity = new Tag();

                objSeedEntity.title = SeedName.Replace("|","&");

                objSeedEntity.description = Description.Replace("|", "&");

                LocationAction objLocation = new LocationAction();
                string cityid = objLocation.GetCityIdByCityName(CityName, RegionCode);
                if (string.IsNullOrEmpty(cityid))
                    cityid = objSeed.AddCity(CityName, RegionCode);

                string lat = Lat;
                string longt = Lng;

                if (cityid.Length > 0)
                {
                    Location objLoc = objLocation.CreateLocation(cityid, (ZipCode).ToString(), Convert.ToDouble(lat), Convert.ToDouble(longt), Street);

                    objSeedEntity.locationId = new Guid(objLoc.id.ToString());

                    objSeedEntity.ownerId = new Guid(ownerId);
                    seedData = objSeed.AddSeed(objSeedEntity);

                    actionCompleted = true;
                    result = seedData.id.ToString();
                    if (!string.IsNullOrEmpty(tagName))
                    {
                        if (seedData.id != null && tagName.Length > 0)
                        {
                            if (!tagName.Equals("(null)"))
                            {
                                objTagEntity.name = tagName;
                                objTagEntity.seedId = seedData.id;
                                actionCompleted = objSeed.ManageTag(objTagEntity);
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(imageName))
                    {
                        if (!imageName.Equals("No Image"))
                        {
                            AddMedia("Iphone Image1", imageName, seedData.id.ToString(), "Image", ownerId);

                            imagePath = System.Configuration.ConfigurationManager.AppSettings["RootURL"].ToString() + "/UploadedMedia/" + imageName;
                        }
                    }
                    if (!string.IsNullOrEmpty(categoryNames))
                    {
                        if (seedData.id != null && categoryNames.Length > 0)
                        {
                            if (!categoryNames.Equals("Select Category"))
                            {
                                string[] arrCategoryIds;
                                string[] arrCategoryNames;
                                string ids = string.Empty;
                                //categoryNames = categoryNames.TrimStart(',');
                                arrCategoryNames = categoryNames.Split(',');
                                CategoryAction objCategory = new CategoryAction();
                                for (int c = 0; c < arrCategoryNames.Length; c++)
                                {
                                    if (!string.IsNullOrEmpty(ids))
                                        ids = ids + "," + objCategory.GetCategoryIdByCategoryName(arrCategoryNames[c].ToString().Trim());
                                    else
                                        ids = objCategory.GetCategoryIdByCategoryName(arrCategoryNames[c].ToString().Trim());
                                }
                                arrCategoryIds = ids.Split(',');
                                if (categoryNames.Trim().ToString() != "" && arrCategoryIds.Length > 0)
                                {
                                    objSeed.AddCategories(seedData.id.ToString(), arrCategoryIds);
                                }
                            }
                        }
                    }

                    result = seedData.id.ToString() + "||" + seedData.title + "||" + CityName + "||" + RegionCode + "||" + ZipCode + "||" + imageName + "||" + imagePath + "||" + DateTime.Now.ToString();
                }
                if (actionCompleted == false)
                {
                    result = "Error while seed planting.";
                }
            }
            catch (Exception ex)
            {
                result = "Error while seed planting.";
            }

            return result;
        }
Beispiel #4
0
        /// <summary>
        /// Method to add new seed.
        /// </summary>
        /// <param name="seed"></param>
        /// <returns></returns>
        public Seed AddSeed(Seed seed)
        {
            #region Business Logic

            try
            {
                seed.id = Guid.NewGuid();
                seed.createDate = DateTime.Now;
                seed.status = SystemStatements.STATUS_NEW;

                repoObj.Create<Seed>(seed);
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
            return seed;
            #endregion
        }
Beispiel #5
0
        /// <summary>
        /// Method to update seed.
        /// </summary>
        /// <param name="seed"></param>
        /// <returns></returns>
        public Seed UpdateSeed(Seed seed)
        {
            #region Business Logic

            try
            {
                repoObj.Update<Seed>(seed);
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
            return seed;
            #endregion
        }
Beispiel #6
0
        private void FixupSeed2(Seed previousValue)
        {
            if (previousValue != null && previousValue.Seed1.Contains(this))
            {
                previousValue.Seed1.Remove(this);
            }

            if (Seed2 != null)
            {
                if (!Seed2.Seed1.Contains(this))
                {
                    Seed2.Seed1.Add(this);
                }
                if (parentSeedID != Seed2.id)
                {
                    parentSeedID = Seed2.id;
                }
            }
            else if (!_settingFK)
            {
                parentSeedID = null;
            }
        }
        public string AddSeedData(AddSeed objAddSeedModel)
        {
            #region
            bool actionCompleted = false;
            Seed seedData = null;
            SeedAction objSeed = new SeedAction();

            Seed objSeedEntity = new Seed();
            Member memberData = new Member();
            Tag objTagEntity = new Tag();

            objSeedEntity.title = objAddSeedModel.SeedName;
            if (!string.IsNullOrEmpty(objAddSeedModel.rootSeedId))
                objSeedEntity.rootSeedID = new Guid(objAddSeedModel.rootSeedId);

            if (!string.IsNullOrEmpty(objAddSeedModel.parentSeedId))
                objSeedEntity.parentSeedID = new Guid(objAddSeedModel.parentSeedId);

            string s = Regex.Replace(objAddSeedModel.Description, @"<(.|\n)*?>", string.Empty);
            s = s.Replace("&nbsp;", " ");
            s = Regex.Replace(s, @"\s+", " ");
            s = Regex.Replace(s, @"\r\n", "\n");
            s = Regex.Replace(s, @"\n+", "\n");
            string description = s;

            if (description.Length > 999)
                description = description.Substring(0, 995);

            badWordsFilter objWords = new badWordsFilter();
            string filePath = Server.MapPath("~/utils/badWords.xml");
            List<string> lstBadWords = badWordsFilter.BadWordList(ref filePath);
            description = objWords.FilterBadWords(lstBadWords, description);

            objSeedEntity.description = description;

            LocationAction objLocation = new LocationAction();
            string cityid = objLocation.GetCityIdByCityName(objAddSeedModel.City, objAddSeedModel.StateCode);
            if (string.IsNullOrEmpty(cityid))
                cityid = objSeed.AddCity(objAddSeedModel.City, objAddSeedModel.StateCode);

            if (string.IsNullOrEmpty(cityid))
                throw new Exception("Please select associated state and city");
            string latLong = objAddSeedModel.LongLat;
            char[] separator = new char[] { ',' };
            string[] strSplitLatLong = latLong.Split(separator);
            string lat = strSplitLatLong[0].ToString();
            string longt = strSplitLatLong[1].ToString();
            string crossStreet = objAddSeedModel.StreetAddress.Trim();
            Location objLoc = objLocation.CreateLocation(cityid, (objAddSeedModel.ZipCode).ToString(), Convert.ToDouble(lat), Convert.ToDouble(longt), crossStreet);

            objSeedEntity.locationId = new Guid(objLoc.id.ToString());

            if (SeedSpeak.Util.SessionStore.GetSessionValue(SeedSpeak.Util.SessionStore.Memberobject) != null)
                memberData = (Member)SeedSpeak.Util.SessionStore.GetSessionValue(SeedSpeak.Util.SessionStore.Memberobject);
            objSeedEntity.ownerId = memberData.id;
            seedData = objSeed.AddSeed(objSeedEntity);

            if (objSeedEntity.id != null)
            {
                if (!string.IsNullOrEmpty(objAddSeedModel.Tag))
                {
                    objTagEntity.name = objAddSeedModel.Tag;
                    objTagEntity.seedId = objSeedEntity.id;
                    actionCompleted = objSeed.ManageTag(objTagEntity);
                }
            }
            if (actionCompleted == false)
            {
                ModelState.AddModelError("", "Error while seed planting.");
                RedirectToAction("AddSeed", "Seed");
            }

            return seedData.id.ToString();
            #endregion
        }