Exemple #1
0
        public async Task <HttpResponseMessage> Post(string id, ExternalVideoModel model)
        {
            // Get project entity
            await GetProjectAsync(id);

            DomainExternalVideo externalVideo = await _externalVideoService.AddAsync(id, model);

            var result = new ExternalVideo
            {
                ProductName  = externalVideo.ProductName,
                VideoUri     = externalVideo.VideoUri,
                AcsNamespace = _settings.AcsNamespace
            };

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, result);

            return(response);
        }
Exemple #2
0
        public async Task <HttpResponseMessage> Post(ExternalProjectModel model)
        {
            try
            {
                await CongratUserIfNeeded();
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to notify user by email: {0}", e);
            }

            // Add project
            ProductType product = _productIdExtractor.Get(UserAgent);

            var project = new DomainProject
            {
                UserId         = UserId,
                Name           = model.Name,
                Description    = model.Description,
                Access         = model.Access,
                ProductType    = product,
                ProjectType    = model.ProjectType,
                ProjectSubtype = model.ProjectSubtype,
                EnableComments = model.EnableComments
            };

            project = await _projectService.AddAsync(project);

            // Add external video
            await _externalVideoService.AddAsync(project.Id, new DomainExternalVideo
            {
                ProductName = model.ProductName,
                VideoUri    = model.VideoUri
            });

            // Add avsx file if exists
            if (model.Avsx != null)
            {
                var avsx = new DomainAvsx
                {
                    ContentType = model.Avsx.ContentType,
                    FileName    = model.Avsx.Name,
                    FileUri     = model.Avsx.Uri,
                    FileLength  = model.Avsx.Length
                };

                await _projectAvsxService.AddAsync(project.Id, avsx);

                // For statistics
                Request.Properties.Add("isAvsx", true);
            }

            // Add screenshot file if exists
            if (model.Screenshot != null)
            {
                var screenshot = new DomainScreenshot
                {
                    FileName    = model.Screenshot.Name,
                    FileUri     = model.Screenshot.Uri,
                    FileId      = Guid.NewGuid().ToString(),
                    FileLength  = model.Screenshot.Length,
                    ContentType = model.Screenshot.ContentType,
                    Created     = DateTime.UtcNow,
                    Modified    = DateTime.UtcNow
                };

                await _projectScreenshotService.AddAsync(project.Id, screenshot);

                // For statistics
                Request.Properties.Add("isScreenshot", true);
            }

            var responseProject = new Project
            {
                Id             = project.Id,
                Description    = project.Description,
                Access         = project.Access,
                Name           = project.Name,
                Created        = project.Created,
                PublicUrl      = _projectUriProvider.GetUri(project.Id),
                ProjectType    = project.ProjectType,
                ProjectSubtype = project.ProjectSubtype,
                EnableComments = project.EnableComments
            };

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, responseProject);

            response.SetLastModifiedDate(project.Modified);

            return(response);
        }