public async Task UploadFile(int id, DetailTypeEnum detailType, CancellationToken cancellationToken)
        {
            if (HttpContext.Current.Request.Files.AllKeys.Any())
            {
                // Get the uploaded image from the Files collection
                var httpPostedFile = HttpContext.Current.Request.Files["UploadedFile"];

                if (httpPostedFile != null)
                {
                    // Validate the uploaded image(optional)
                    var guid = Guid.NewGuid();
                    // Get the complete file path
                    string directory = string.Empty;
                    switch (detailType)
                    {
                    case DetailTypeEnum.Picture:
                        directory = Path.Combine(HttpContext.Current.Server.MapPath(string.Format("~/UploadedFiles/{0}/Picture/{1}", id, guid.ToString())));
                        break;

                    case DetailTypeEnum.Video:
                        directory = Path.Combine(HttpContext.Current.Server.MapPath(string.Format("~/UploadedFiles/{0}/Video/{1}", id, guid.ToString())));
                        break;
                    }

                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }
                    var fileSavePath = string.Format("{0}/{1}", directory, httpPostedFile.FileName);

                    // Save the uploaded file to "UploadedFiles" folder
                    httpPostedFile.SaveAs(fileSavePath);
                    _hsrDb.CanibetDetails.Add(new CanibetDetail()
                    {
                        CanibetID  = id,
                        CreateDate = DateTime.Now,
                        UpdateDate = DateTime.Now,
                        Directory  = guid.ToString(),
                        FileName   = httpPostedFile.FileName,

                        Type      = detailType,
                        MediaType = httpPostedFile.ContentType,
                    });
                    await _hsrDb.SaveChangesAsync(cancellationToken);
                }
            }
        }
        public static dynamic GetTSObject(DetailTypeEnum dynEnum)
        {
            var tsType = TSActivator.CreateInstance("Tekla.Structures.DetailTypeEnum").GetType();

            switch (dynEnum)
            {
            case DetailTypeEnum.END:
                return(System.Enum.Parse(tsType, "END"));

            case DetailTypeEnum.INTERMEDIATE:
                return(System.Enum.Parse(tsType, "INTERMEDIATE"));

            case DetailTypeEnum.INTERMEDIATE_REVERSE:
                return(System.Enum.Parse(tsType, "INTERMEDIATE_REVERSE"));

            default:
                throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented");
            }
        }
        public async Task <dynamic> GetCanibetFile(int id, DetailTypeEnum detailType, CancellationToken cancellationToken)
        {
            _hsrDb.Configuration.LazyLoadingEnabled = false;
            var files = await _hsrDb.CanibetDetails.Where(c => c.Type == detailType && c.CanibetID == id).ToListAsync(cancellationToken);

            List <CanibetDetailModel> resObj = new List <CanibetDetailModel>();

            foreach (var file in files)
            {
                resObj.Add(new CanibetDetailModel()
                {
                    CanibetID       = file.CanibetID,
                    CanibetDetailID = file.CanibetDetailID,
                    Announcement    = file.Announcement,
                    Directory       = file.Directory,
                    FileName        = file.FileName,
                    MediaType       = file.MediaType,
                    Type            = file.Type,
                    Css             = resObj.Count == 0 ? "active" : ""
                });
            }

            return(resObj);
        }
Пример #4
0
 public static DetailViewModel GetDetail(this CombinedRelationshipReadModel member, DetailTypeEnum detailType)
 {
     return(member?.Details?.FirstOrDefault(x => x.DetailType == detailType));
 }
Пример #5
0
        public async Task <DetailReadModel> CreateDetail(Guid memoryBookUniverseId, MemberReadModel creator, string customDetailText, DetailTypeEnum detailType, DateTime?startDate, DateTime?endDate = null)
        {
            Contract.RequiresNotNull(creator, nameof(creator));

            var detailTypeReadModel = await this.GetDetailType(detailType).ConfigureAwait(false);

            DetailCreateModel detailCreateModel = new DetailCreateModel
            {
                StartTime        = startDate,
                EndTime          = endDate,
                CreatorId        = creator.Id,
                CustomDetailText = customDetailText,
                DetailTypeId     = detailTypeReadModel.Id
            };

            return(await this.CreateDetail(memoryBookUniverseId, detailCreateModel)
                   .ConfigureAwait(false));
        }
Пример #6
0
        private async Task <DetailTypeReadModel> GetDetailType(DetailTypeEnum detailType)
        {
            var types = await this.GetDetailTypes().ConfigureAwait(false);

            return(types.First(x => x.Code.Equals(detailType.ToString())));
        }
Пример #7
0
 public static DetailViewModel GetDetail(this MemberViewModel member, DetailTypeEnum detailType)
 {
     return(member?.Details?.FirstOrDefault(x => x.DetailType == detailType));
 }