示例#1
0
 public static FrontContent Map(FrontContentModel objModel)
 {
     return(new FrontContent
     {
         Id = objModel.Id,
         SectionId = objModel.SectionId,
         ContentId = objModel.ContentId,
         CreateDate = objModel.CreateDate
     });
 }
        public ActionResult AddRemovePublic(int id, int sectionId)
        {
            var objFrontContent = _repoFrontContent.GetSingle(x => x.ContentId == id && x.SectionId == sectionId);

            if (objFrontContent == null)
            {
                FrontContentModel FrontContent = new FrontContentModel();
                FrontContent.SectionId  = sectionId;
                FrontContent.ContentId  = id;
                FrontContent.CreateDate = DateTime.Now;
                _repoFrontContent.Add(FrontContentMap.Map(FrontContent));
                _repoFrontContent.Save();
                return(Json(new { status = "success", message = "added" }));
            }
            else
            {
                _repoFrontContent.Delete(objFrontContent);
                _repoFrontContent.Save();
                return(Json(new { status = "success", message = "deleted" }));
            }
        }
示例#3
0
        public PartialViewResult FrontList(string name, string countryName, int?provinceId, int?disciplineId, string sex, int?categoryId, int?sortOrder, int?pageNumber = null, int?itemsPerPage = null)
        {
            int profileListCount = 0;
            int groupListCount   = 0;
            int offset           = 0;

            offset = (((int)pageNumber - 1) * (int)itemsPerPage);
            List <FrontContentModel> lstFrontContent = new List <FrontContentModel>();
            FrontContentModel        objFrontContent = new FrontContentModel();

            objFrontContent.UserProfiles = new List <UserProfileModel>();
            objFrontContent.Groups       = new List <GroupModel>();
            lstFrontContent = FrontContentMap.Map(_repFrontContent.GetList(x => true).ToList());
            List <long> lstUserProfileId = new List <long>();
            List <long> lstGroupId       = new List <long>();

            if (lstFrontContent.Count != 0)
            {
                ////For listing Front Profiles Contents
                lstUserProfileId = lstFrontContent.Where(x => x.SectionId == 1).Select(x => x.ContentId).ToList();

                foreach (long item in lstUserProfileId)
                {
                    var objuser = _repUserProfile.GetSingle(x => x.Id == item);
                    if (objuser != null)
                    {
                        UserProfileModel objUserProfile = UserProfileMap.Map(objuser);
                        objFrontContent.UserProfiles.Add(objUserProfile);
                        profileListCount++;
                        var objEntityFile = _repEntityFile.GetSingle(x => x.EntityId == item && x.Section.SectionName == "Users");
                        if (objEntityFile != null)
                        {
                            objUserProfile.FileId = objEntityFile.FileId;
                        }
                    }
                }

                lstGroupId     = lstFrontContent.Where(x => x.SectionId == 2).Select(x => x.ContentId).ToList();
                groupListCount = lstGroupId.Count;
                foreach (long item in lstGroupId)
                {
                    GroupModel objGroups = GroupMap.Map(_repGroup.GetSingle(x => x.Id == item));
                    if (objGroups != null)
                    {
                        objFrontContent.Groups.Add(objGroups);

                        var objEntityFile = _repEntityFile.GetSingle(x => x.EntityId == item && x.Section.SectionName == "Groups");
                        if (objEntityFile != null)
                        {
                            objGroups.FileId = objEntityFile.FileId;
                        }
                    }
                }
            }
            ViewBag.PagedListofUserProfiles = objFrontContent.UserProfiles ?? new List <UserProfileModel>();
            ViewBag.PagedListofGroups       = objFrontContent.Groups ?? new List <GroupModel>();

            ViewBag.TotalCount = profileListCount + groupListCount;

            return(PartialView("_FrontContentList"));
        }