Beispiel #1
0
        // GET: /Admin/ManageContent/
        // [AuditLog(Event = "Manage Content", Message = "Manage Content")]
        public ActionResult Index()
        {
            smContentLibrary content = new smContentLibrary();

            if (smartData.Common.SessionManager.LoggedInUser.UserType == 3)//superadmin
            {
                content.categoryList = new SelectList(_manageContentAPIController.GetCategories(), "IndustryId", "IndustryName");
            }
            else
            {
                smIndustry newlist = _manageContentService.GetIndustryById(smartData.Common.SessionManager.LoggedInUser.IndustryId);
                ViewBag.IndustryId   = newlist.IndustryId.ToString();
                ViewBag.IndustryName = newlist.IndustryName.ToString();
            }
            TempData["img"] = false;
            return(View(content));
        }
Beispiel #2
0
        public smPost SaveScheduledPosts(smContentLibrary post, DateTime dt, int UserId, int ImpersonateUserId, int Fid, string socialarr, int EventId)
        {
            smPost entity = new smPost();

            try
            {
                List <smContentLibrary> data = Context.Set <smContentLibrary>().Where(x => x.GroupId.ToLower().Trim() == post.GroupId.ToLower().Trim()).Select(y => y).ToList();
                var strArra = socialarr.Split(',').ToList();
                data = data.Where(x => strArra.Any(l => x.SocialMedia.ToLower() == l.ToLower())).ToList();
                List <smPost> FinalData = data.Select(s => new smPost

                {
                    UserId       = UserId,
                    EventId      = EventId,
                    Caption      = s.Heading,
                    Name         = s.Title.Replace("’", "'"),
                    Url          = s.Url,
                    UniquePostId = RandomString(8),
                    ImageUrl     = s.ImageUrl,

                    Description          = s.Description.Replace("’", "'"),
                    PostDate             = dt,
                    ModifiedDate         = DateTime.UtcNow,
                    IsPosted             = false,
                    CreatedDate          = new DateTime?(DateTime.UtcNow),
                    PostType             = 2,
                    IsActive             = true,
                    IsDeleted            = false,
                    SocialMedia          = s.SocialMedia,
                    CreatedBy            = ImpersonateUserId == 0 ? UserId : ImpersonateUserId,
                    ContentId            = s.ContentId,
                    SocialMediaProfileId = Context.Set <smSocialMediaProfile>().Where(x => x.SocialMedia.ToLower() == s.SocialMedia.ToLower() && x.UserId == UserId).Select(x => x.Fid).FirstOrDefault(),
                }).ToList();
                Context.Set <smPost>().AddRange(FinalData);
                Context.SaveChanges();
            }
            catch (Exception)
            {
            }
            return(entity);
        }
Beispiel #3
0
 public smPost SaveScheduledPosts(smContentLibrary post, DateTime dt, int UserId, int ImpersonateUserId, int Fid, string socialarr, int EventId)
 {
     return(_postRepository.SaveScheduledPosts(post, dt, UserId, ImpersonateUserId, Fid, socialarr, EventId));
 }
Beispiel #4
0
        public JsonResult EditContent(int id)
        {
            smContentLibrary content = _manageContentAPIController.EditContent(id);

            return(Json(new { result = content }));
        }
        //public List<smContentLibrary> GetCategoryListforcalender(int IndustryId, List<smPreference> list)
        //{
        //    List<smContentLibrary> library = Context.Set<smContentLibrary>().Where(x => x.CategoryId == IndustryId && x.IsActive == true && x.IsDeleted == false && x.SocialMedia != "Rss").ToList();
        //    List<smContentLibrary> smContentLibrary = new List<smContentLibrary>();
        //    if (list.Count != 0)
        //    {
        //        foreach (var item in library)
        //        {
        //            if (!string.IsNullOrEmpty(item.SubIndustryName))
        //            {
        //                List<smPreference> catg = list.Where(x => x.Preference.ToLower() == item.SubIndustryName.ToLower()).ToList();
        //                smContentLibrary.Add(item);
        //            }
        //        }
        //    }
        //    return smContentLibrary;
        //}



        public List <smContentLibrary> GetCategoryListforcalender(int IndustryId, List <smPreference> list, int userId, string data)
        {
            var myvar = from a in Context.Set <smContentLibrary>().Where(x => x.CategoryId == IndustryId && x.IsActive == true && !x.IsDeleted)
                        join b in Context.Set <smSocialMediaProfile>().Where(x => x.UserId == userId) on a.SocialMedia equals b.SocialMedia
                        select new { a };


            // var rssContent = Context.Set<smContentLibrary>().Where(x => x.CategoryId == IndustryId && x.IsActive && !x.IsDeleted && x.SocialMedia != "Rss").ToList();

            List <smContentLibrary> list2 = new List <smContentLibrary>();

            foreach (var item in myvar)
            {
                list2.Add(item.a);
            }

            //  list2.AddRange(rssContent);



            //List<smContentLibrary> list2 = (from x in base.Context.Set<smContentLibrary>()
            //                              ///  where (((x.CategoryId == IndustryId) && x.IsActive) && !x.IsDeleted) && (x.SocialMedia != "Rss")    ///old
            //                                where (((x.CategoryId == IndustryId) && x.IsActive) && !x.IsDeleted)    /// new SRohit
            //                                select x).ToList<smContentLibrary>();
            List <smContentstatus> list3 = (from x in base.Context.Set <smContentstatus>()
                                            where x.UserId == userId
                                            select x).ToList <smContentstatus>();
            List <smContentLibrary> source = new List <smContentLibrary>();

            if (list.Count != 0)
            {
                //using (List<smContentLibrary>.Enumerator enumerator = list2.GetEnumerator())
                //{
                //    while (enumerator.MoveNext())
                //    {
                //        Func<smPreference, bool> predicate = null;
                //        smContentLibrary item = enumerator.Current;
                //        if (!string.IsNullOrEmpty(item.SubIndustryName))
                //        {
                //            if (predicate == null)
                //            {
                //                predicate = x => x.Preference.ToLower() == item.SubIndustryName.ToLower();
                //            }
                //            list.Where<smPreference>(predicate).ToList<smPreference>();
                //            source.Add(item);

                //        }
                //    }
                //}
                var preferenceList = list.Select(x => x.Preference).ToList();
                source = list2.Where(m => preferenceList.Contains(m.SubIndustryName)).ToList();
            }

            List <smContentLibrary> second = new List <smContentLibrary>();
            List <smContentLibrary> list6  = new List <smContentLibrary>();

            if (list3.Count != 0)
            {
                using (List <smContentstatus> .Enumerator enumerator2 = list3.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        Func <smContentLibrary, bool> func2 = null;
                        smContentstatus it = enumerator2.Current;
                        if (func2 == null)
                        {
                            func2 = x => x.ContentId == it.ContentId;
                        }
                        smContentLibrary library = source.Where <smContentLibrary>(func2).FirstOrDefault <smContentLibrary>();
                        second.Add(library);
                        list6 = source.Except <smContentLibrary>(second).ToList <smContentLibrary>();
                    }
                    //  return list6;


                    var AddedList = Context.Set <smPost>().Where(x => x.UserId == userId).Select(x => x.ContentId).ToList();
                    var OldList   = list6.Where(e => AddedList.Contains(e.ContentId));
                    var NewList   = list6.Where(e => !AddedList.Contains(e.ContentId));
                    if (!String.IsNullOrEmpty(data))
                    {
                        if (data == "0")
                        {
                            return(OldList.ToList());
                        }
                        else
                        {
                            return(NewList.ToList());
                        }
                    }
                }
            }
            var AddedLists = Context.Set <smPost>().Where(x => x.UserId == userId).Select(x => x.ContentId).ToList();
            var OldLists   = source.Where(e => AddedLists.Contains(e.ContentId));
            var NewLists   = source.Where(e => !AddedLists.Contains(e.ContentId));

            if (!String.IsNullOrEmpty(data))
            {
                if (data == "0")
                {
                    return(OldLists.ToList());
                }
                else
                {
                    return(NewLists.ToList());
                }
            }
            else
            {
                return(source);
            }
        }
Beispiel #6
0
        public int AddRssData(string message, string imageIds, string url, int userId, int categoryId, string socialMedia, string categoryName, DateTime CreatedDate, string textdescription, string Subindustryname, string Heading, string OriginalTitle, int FeedID)
        {
            // bool status = false;
            if (!String.IsNullOrEmpty(textdescription))
            {
                textdescription = textdescription.Replace("’", "'");
            }
            if (!String.IsNullOrEmpty(message))
            {
                message = message.Replace("’", "'");
            }

            int    flag    = 1;
            string Message = string.Empty;

            try
            {
                string image     = string.Empty;
                string imagePath = string.Empty;
                if (!string.IsNullOrEmpty(imageIds))
                {
                    if (Uri.IsWellFormedUriString(imageIds, UriKind.RelativeOrAbsolute))
                    {
                        imagePath = imageIds;
                    }
                    else
                    {
                        imagePath = "/Images/WallImages/ContentImages/" + imageIds;
                    }
                }
                else
                {
                    imagePath = null;
                }
                //if (imageIds.Count != 0)
                //{
                //    image = imageIds[0];
                //    if (image != string.Empty)
                //    {
                //        imagePath = image;
                //    }
                //    else
                //    {
                //        imagePath = null;
                //    }
                //}

                smContentLibrary content = new smContentLibrary();
                content.UserId      = userId;
                content.SocialMedia = socialMedia;
                content.CategoryId  = categoryId;
                //content.Tags = tags;
                string string1 = message.Replace("&#39;", "").Trim();
                string str     = textdescription.Replace("/'", "").Trim();
                string result  = string1.TrimStart(str.ToCharArray());
                //  content.Description = result;
                content.Description     = string1;
                content.Title           = textdescription;
                content.Url             = url;
                content.ImageUrl        = imagePath;
                content.CreatedBy       = userId;
                content.CreatedDate     = DateTime.UtcNow;
                content.IsActive        = true;
                content.IsDeleted       = false;
                content.CategoryName    = categoryName;
                content.SubIndustryName = Subindustryname;
                content.Heading         = Heading;
                content.GroupId         = RandomString(10);
                content.OriginalTitle   = OriginalTitle;

                // content.CreatedDate = CreatedDate;
                string Des = string.Empty;
                //string DesCheck=string.Empty;
                int?id = 0;
                //var CheckTittle = Context.Set<smContentLibrary>().Where(x => x.Description == content.Description &  x.CreatedBy == content.UserId);
                var CheckTittle = Context.Set <smContentLibrary>().Where(x => x.Description == content.Description);

                foreach (var item in CheckTittle.ToList())
                {
                    Des = item.Description;
                    id  = item.CreatedBy;
                }
                if (Des == "")
                {
                    int feedID  = Convert.ToInt32(FeedID);
                    var RssData = Context.Set <smRssFeeds>().Where(x => x.FeedId == feedID).FirstOrDefault();
                    if (RssData != null)
                    {
                        RssData.DateProcess = DateTime.UtcNow;
                    }
                    Context.Set <smContentLibrary>().Add(content);
                    Context.SaveChanges();
                    flag = 1;
                }

                else
                {
                    flag = 2;
                }
            }
            catch
            {
                flag = 3;
                // status = false;
            }


            return(flag);
        }