Beispiel #1
0
        public int AddUpdateTraining(TrainingViewModel model, int userid, int OrganizationId)
        {
            Training training = Mapper.Map <TrainingViewModel, Training>(model);

            if (model.TrainingId == 0)
            {
                training.Active         = true;
                training.CreatedBy      = userid;
                training.CreatedOn      = DateTime.Now;
                training.OrganisationID = OrganizationId;
                base.Insert(training);
                this._unitOfWork.Save();
            }
            else
            {
                training = GetSingle(model.TrainingId, OrganizationId);
                training.TrainingNeed         = model.TrainingNeed;
                training.TrainerRequired      = model.TrainerRequired;
                training.TrainingType         = model.TrainingType;
                training.TrainingEventID      = model.TrainingEventID;
                training.IsAssignmentRequired = model.IsAssignmentRequired;
                training.AssignmentID         = model.AssignmentID;
                base.Update(training);
            }
            if (!string.IsNullOrWhiteSpace(model.YouTubeLink))
            {
                TrainingMaterial material = new TrainingMaterial();
                material.YouTubeLink    = model.YouTubeLink;
                material.TrainingId     = training.TrainingId;
                material.OrganizationId = OrganizationId;
                this._ITrainingMaterialRepository.Add(material, OrganizationId);
            }
            this._unitOfWork.Save();
            return(training.TrainingId);
        }
Beispiel #2
0
        public Response AddTrainingMaterial(TrainingMaterialRequest request)
        {
            var validationResult = trainingMaterialRequestValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                return(Response.CreateResponse(validationResult.Messages));
            }

            var handler        = fileHandlerFactory.GetFileHandler(request.ContentType);
            var uploadResponse = handler.Upload(new UploadRequest {
                ContentType      = request.ContentType,
                OriginalFileName = request.OriginalFileName,
                Stream           = request.Stream,
                Description      = request.Description,
                Title            = request.Title
            });

            if (!uploadResponse.Response.RequestIsFulfilled)
            {
                return(Response.CreateResponse(uploadResponse.Response.Errors));
            }

            TrainingMaterial material = MapTrainingMaterial(request, uploadResponse.Result);

            try {
                libraryRepository.AddTrainingMaterial(material);
                return(Response.CreateSuccessResponse());
            } catch (Exception ex) {
                return(Response.CreateResponse(ex));
            } finally {
                UpdateCache(request.ClubId);
            }
        }
Beispiel #3
0
 public void UpdateTrainingMaterial(TrainingMaterial trainingMaterial)
 {
     ThrowIf.ArgumentIsNull(trainingMaterial);
     using (var connection = connectionFactory.Connect()) {
         string            sql = GetUpdateStatement();
         DynamicParameters p   = SetupUpdateParameters(trainingMaterial);
         connection.Open();
         connection.Execute(sql, p);
     }
 }
        public string DeleteMaterial(int id)
        {
            TrainingMaterial data = this._ITrainingMaterialRepository.Delete(id, base.OrganizationId);

            if (!string.IsNullOrWhiteSpace(data.FilePath))
            {
                var    path          = HttpRuntime.AppDomainAppPath;
                string directoryName = System.IO.Path.Combine(path, data.FilePath.Replace("~/", string.Empty));
                System.IO.File.Delete(directoryName);
            }
            return("");
        }
Beispiel #5
0
        private DynamicParameters SetupUpdateParameters(TrainingMaterial trainingMaterial)
        {
            var p = new DynamicParameters();

            p.Add("@TrainingMaterialGuid", trainingMaterial.Guid.ToString());
            p.Add("@Title", trainingMaterial.Title);
            p.Add("@Description", trainingMaterial.Description);
            p.Add("@ContentType", trainingMaterial.ContentType);
            p.Add("@ExternalId", trainingMaterial.ExternalId);
            p.Add("@Url", trainingMaterial.Url);
            p.Add("@ThumbnailUrl", trainingMaterial.ThumbnailUrl);
            return(p);
        }
        public int AddUpdateTrainingMaterial(TrainingMaterialViewModel model, int userid, int OrganizationId)
        {
            TrainingMaterial training = Mapper.Map <TrainingMaterialViewModel, TrainingMaterial>(model);

            training.OrganizationId = OrganizationId;
            if (model.TrainingMaterialId == 0)
            {
                base.Insert(training);
            }
            else
            {
                training = GetSingle(model.TrainingMaterialId, OrganizationId);
                base.Update(training);
            }
            this._unitOfWork.Save();
            return(training.TrainingMaterialId);
        }
Beispiel #7
0
        public (Metadata Metadata, Response Response) GetMetaData(TrainingMaterial trainingMaterial)
        {
            long clipId = 0;
            var  client = new VimeoClient(config.VideoSettings.Token);

            if (!long.TryParse(trainingMaterial.ExternalId, out clipId))
            {
                return(null, Response.CreateResponse(new IllegalOperationException("The training material id could not be converted into the desired format (string to long)")));
            }

            try {
                var video = client.GetVideoAsync(clipId).Result;
                if (video == null || video.id != clipId)
                {
                    return(null, Response.CreateResponse(new EntityNotFoundException("The desired video could not be retrieved from the host service (Vimeo)")));
                }

                return(new Metadata {
                    Status = video.status, Thumbnail = (video.pictures?.sizes?.Count > 0 ? video.pictures.sizes[0].link : string.Empty), Url = video.StandardVideoLink
                }, Response.CreateSuccessResponse());
            } catch (Exception ex) {
                return(null, Response.CreateResponse(ex));
            }
        }
Beispiel #8
0
 public (Metadata Metadata, Response Response) GetMetaData(TrainingMaterial trainingMaterial)
 {
     throw new NotImplementedException();
 }
 public void Update(TrainingMaterial entity, int LoggedInUserId, int LoggedInOrganizationId)
 {
     base.Update(entity);
     _unitOfWork.Save();
 }