Exemplo n.º 1
0
        public async Task<HttpResponseMessage> Post(ProjectModel model)
        {
            try
            {
                await CongratUserIfNeeded();
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to notify user by email: {0}", e);
            }

            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);

            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;
        }
Exemplo n.º 2
0
        public async Task<HttpResponseMessage> Put(string id, ProjectModel model)
        {
            var project = new DomainProject { Id = id, UserId = UserId };
            DomainProject originalProject = await _projectService.GetAsync(project);

            // updating original project
            originalProject.Name = model.Name;
            originalProject.Description = model.Description;
            originalProject.Access = model.Access;
            originalProject.EnableComments = model.EnableComments;
            project = await _projectService.EditAsync(originalProject);

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

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, responseProjects);
            response.SetLastModifiedDate(project.Modified);

            return response;
        }