示例#1
0
        private AttachmentViewData UploadForSysAdmin(string filename, byte[] bin)
        {
            var key = $"{Context.Role.LoweredName}_{DateTime.UtcNow.ToString("yyyyMMdd_hhmmss")}_{Guid.NewGuid().ToString("N")}";

            SchoolLocator.StorageBlobService.AddBlob(PICTURE_CONTAINER_ADDRESS, key, bin);

            return(AttachmentViewData.CreateForSysAdmin(filename, key));
        }
示例#2
0
        public ActionResult List(IntList ids)
        {
            var attachments = new PaginatedList <AttachmentInfo>(ids
                                                                 .Select(x => SchoolLocator.AttachementService.GetAttachmentById(x))
                                                                 .Select(x => SchoolLocator.AttachementService.TransformToAttachmentInfo(x))
                                                                 , 0, ids.Count);

            return(Json(attachments.Transform(x => AttachmentViewData.Create(x, Context))));
        }
示例#3
0
        public ActionResult AttachmentsList(string filter, int?sortType, int?start, int?count)
        {
            start = start ?? 0;
            count = count ?? 10;
            var attachments = SchoolLocator.AttachementService.GetAttachmentsInfo(filter, (AttachmentSortTypeEnum?)sortType, start.Value, count.Value);

            return(Json(attachments
                        .Transform(x => AttachmentViewData.Create(x, Context))));
        }
示例#4
0
        private AttachmentViewData UploadAttachment(string fileName, byte[] bin)
        {
            if (!Context.SchoolId.HasValue || !Context.DistrictId.HasValue)
            {
                return(UploadForSysAdmin(fileName, bin));
            }

            Trace.Assert(Context.PersonId.HasValue);

            var attachment = SchoolLocator.AttachementService.Upload(fileName, bin);
            var res        = SchoolLocator.AttachementService.TransformToAttachmentInfo(attachment, new List <int> {
                Context.PersonId.Value
            });

            return(AttachmentViewData.Create(res, Context, true));
        }
        public static AnnouncementAssignedAttributeViewData Create(AnnouncementAssignedAttribute attr, AttachmentInfo attachmentInfo)
        {
            var result = new AnnouncementAssignedAttributeViewData
            {
                Id                             = attr.Id,
                Name                           = attr.Name,
                Text                           = attr.Text,
                AttributeTypeId                = attr.AttributeTypeId,
                VisibleForStudents             = attr.VisibleForStudents,
                AnnouncementRef                = attr.AnnouncementRef,
                SisActivityAssignedAttributeId = attr.SisActivityAssignedAttributeId,
                AttributeAttachment            = attachmentInfo != null?AttachmentViewData.Create(attachmentInfo) : null
            };

            return(result);
        }