public async Task <HttpResponseMessage> Post(string id, ProjectAvsxModel model) { // Get project entity await GetProjectAsync(id); // Add avsx var avsx = new DomainAvsx { ContentType = model.Avsx.ContentType, FileName = model.Avsx.Name, FileUri = model.Avsx.Uri, FileLength = model.Avsx.Length }; avsx = await _projectAvsxService.AddAsync(id, avsx); var responseAvsx = new ProjectAvsx { Name = avsx.FileName, Uri = avsx.FileUri, Length = avsx.FileLength, ContentType = avsx.ContentType }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, responseAvsx); response.SetLastModifiedDate(avsx.Modified); return(response); }
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); }