Beispiel #1
0
        // GET: Attachment/Details/5
        public async Task <JsonResult> GetRecords(AttachmentIndexViewModel vmodel)
        {
            int serverCount = 0;

            //Save settings
            savePagePref(vmodel);
            var query = unitOfWork.attachments.get();

            serverCount = query.Count();
            var lst = await query
                      .Skip(vmodel.getStartRecord.Value).Take(vmodel.getRecordCount.Value)
                      .OrderByDescending(q => q.createDt)
                      .Select(q => new AttachmentViewModel {
                id               = q.id,
                sectionId        = q.attachmentSectionEnum,
                isOn             = q.isOn,
                fileName         = q.fileName,
                originalFileName = q.originalFileName,
                url              = fileHelper.generateAssetURL("gallery", q.fileName, true),
                pictureUrl       = fileHelper.generateAssetURL("gallery", q.fileName, false)
            }).ToListAsync();


            return(Json(new { items = lst, itemServerCount = serverCount }));
        }
Beispiel #2
0
        //public FileResult View(string type, string fileName, bool thumbnail)
        //{
        //    string path;
        //    if (fileHelper.getExtension(fileName) == "pdf")
        //    {
        //        if (thumbnail)
        //            path = fileHelper.mapAssetPath(type, fileHelper.getFileName(fileName) + ".jpg", thumbnail);
        //        else
        //            path = fileHelper.mapAssetPath(type, fileHelper.getFileName(fileName) + ".pdf", thumbnail);
        //    }
        //    else
        //    {
        //        path = fileHelper.mapAssetPath(type, fileName, thumbnail);
        //    }
        //    return (new FileResult());
        //}
        // GET: Attachment
        public ActionResult Index()
        {
            AttachmentIndexViewModel vmodel = loadPagePref <AttachmentIndexViewModel>(defaultPref: () =>
            {
                return(new AttachmentIndexViewModel
                {
                    getStartRecord = 0,
                    getRecordCount = 80,
                    status = "incomplete",
                    sortkey = "project",
                    sortdir = 1
                });
            });
            var names             = Enum.GetNames(typeof(AttachmentSectionEnum));
            var attachSectionlist = new object[names.Length];

            for (int i = 0; i < names.Length; i++)
            {
                var value = (AttachmentSectionEnum)Enum.Parse(typeof(AttachmentSectionEnum), names[i]);
                attachSectionlist[i] = new { id = value, name = names[i] };
            }
            ViewBag.sectionList = attachSectionlist;
            return(View(vmodel));
        }