Example #1
0
        public async Task <ActionResult> GetView(string viewName, int memberId)
        {
            ModuleBase viewModel = null;
            var        viewPath  = "/Views/Member/";

            switch (viewName.ToLower())
            {
            case "awards":
            {
                viewModel = new MemberAwards(memberId);
                viewPath += "_MemberAwards.cshtml";
                break;
            }

            case "activity":
            {
                viewModel = new MemberContacts(memberId);
                viewPath += "_MemberActivity.cshtml";
                break;
            }

            case "messages":
            {
                viewModel = new MemberMessages(memberId);
                viewPath += "_MemberMessages.cshtml";
                break;
            }

            case "notes":
            {
                viewModel = new MemberNotes(memberId);
                viewPath += "_MemberNotes.cshtml";
                break;
            }

            case "history":
            {
                viewModel = new MemberActivity(memberId);
                viewPath += "_MemberHistory.cshtml";
                break;
            }


            default:
            {
                var mpjson = await _apiProvider.GetItemAsync("/api/member/GetProfile", $"id={memberId}");

                var mp = _apiProvider.DeserializeJson <cm.MemberProfile>(mpjson);
                viewModel = CopyMemberProfileToVm(mp);
                viewPath += "_MemberProfile.cshtml";
                break;
            }
            }

            return(PartialView(viewPath, viewModel));
        }
Example #2
0
        public ActionResult MemberDetail(int id, string sortOrder, int mdPage = 1)
        {
            ViewBag.Members = "active";

            var user = db.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault();


            var Users        = db.Users.Where(x => x.IsActive == true && x.ID == id).FirstOrDefault();
            var UsersProfile = db.UserProfiles.Where(x => x.UserID == Users.ID).FirstOrDefault();
            int c            = Convert.ToInt32(UsersProfile.Country);
            var Country      = db.Countries.Where(x => x.ID == c && x.IsActive == true).FirstOrDefault();

            var Notes = db.SellerNotes.Where(x => x.IsActive == true && x.SellerID == Users.ID && (x.Status != 1)).ToList();

            List <MemberNotes> list = new List <MemberNotes>();

            foreach (var item in Notes)
            {
                int dn = db.Downloads.Where(x => x.NoteID == item.ID && x.IsSellerHasAllowedDownload == true && x.Seller == Users.ID).Count();
                int te;
                var teList = db.Downloads.Where(x => x.NoteID == item.ID && x.IsSellerHasAllowedDownload == true && x.Seller == Users.ID).ToList();
                if (teList == null)
                {
                    te = 0;
                }
                else
                {
                    te = (int)teList.Sum(x => x.PurchasedPrice);
                }

                MemberNotes members = new MemberNotes()
                {
                    SellerNote      = item,
                    DownloadedNotes = dn,
                    TotalEarning    = te
                };
                list.Add(members);
            }

            ViewBag.TitleSortParm    = sortOrder == "Title" ? "Title_desc" : "Title";
            ViewBag.CategorySortParm = sortOrder == "Category" ? "Category_desc" : "Category";
            ViewBag.StatusSortParm   = sortOrder == "Status" ? "Status_desc" : "Status";
            ViewBag.DnSortParm       = sortOrder == "Dn" ? "Dn_desc" : "Dn";
            ViewBag.TeSortParm       = sortOrder == "Te" ? "Te_desc" : "Te";
            ViewBag.ADateSortParm    = sortOrder == "ADate" ? "ADate_desc" : "ADate";
            ViewBag.PDateSortParm    = sortOrder == "PDate" ? "PDate_desc" : "pDate";


            switch (sortOrder)
            {
            case "Title_desc":
                list = list.OrderByDescending(s => s.SellerNote.Title).ToList();
                break;

            case "Title":
                list = list.OrderBy(s => s.SellerNote.Title).ToList();
                break;

            case "Category_desc":
                list = list.OrderByDescending(s => s.SellerNote.NoteCategory.Name).ToList();
                break;

            case "Category":
                list = list.OrderBy(s => s.SellerNote.NoteCategory.Name).ToList();
                break;

            case "Status_desc":
                list = list.OrderByDescending(s => s.SellerNote.ReferenceData.Value).ToList();
                break;

            case "Status":
                list = list.OrderBy(s => s.SellerNote.ReferenceData.Value).ToList();
                break;

            case "Dn_desc":
                list = list.OrderByDescending(s => s.DownloadedNotes).ToList();
                break;

            case "Dn":
                list = list.OrderBy(s => s.DownloadedNotes).ToList();
                break;

            case "Te_desc":
                list = list.OrderByDescending(s => s.TotalEarning).ToList();
                break;

            case "Te":
                list = list.OrderBy(s => s.TotalEarning).ToList();
                break;

            case "ADate_desc":
                list = list.OrderByDescending(s => s.SellerNote.CreatedDate).ToList();
                break;

            case "ADate":
                list = list.OrderBy(s => s.SellerNote.CreatedDate).ToList();
                break;

            case "PDate_desc":
                list = list.OrderByDescending(s => s.SellerNote.PublishedDate).ToList();
                break;

            case "PDate":
                list = list.OrderBy(s => s.SellerNote.PublishedDate).ToList();
                break;

            default:
                list = list.OrderBy(s => s.SellerNote.CreatedDate).ToList();
                break;
            }

            var pager = new ADPager(list.Count(), mdPage);

            ViewBag.currentPage = pager.CurrentPage;
            ViewBag.endPage     = pager.EndPage;
            ViewBag.startpage   = pager.StartPage;
            ViewBag.pageNumber  = mdPage;

            ViewBag.srno = mdPage;
            ViewBag.TotalMemberDetailPage = Math.Ceiling(list.Count() / 5.0);
            list = list.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList();


            MemberDetailModel member = new MemberDetailModel();

            member.User        = Users;
            member.UserProfile = UsersProfile;
            member.Notes       = list;
            member.CountryName = Country == null ? "" :Country.Name;


            return(View(member));
        }