/// <summary> /// Creates a generic upload. /// </summary> /// <param name="model">The upload to create.</param> /// <param name="unitOfWork">Unit of work.</param> /// <returns>Upload populated with newly allocated upload identifier.</returns> private Upload CreateUpload(CreateUploadModel model, IUnitOfWork unitOfWork) { // Validate create upload model _uploadValidator.ValidateCreateUpload(model); // Construct upload object DateTime now = DateTime.UtcNow; Upload upload = new Upload { TenantId = model.TenantId, Created = now, Updated = now, Name = model.Name.Trim(), Content = model.Content, ContentType = model.ContentType.Trim().ToLower(), Size = model.Content.Length, UploadType = UploadType.Upload, Committed = false }; // Create upload and record newly allocated upload identifier upload.UploadId = _uploadRepository.CreateUpload(upload, unitOfWork); // Return upload object return(upload); }