Ejemplo n.º 1
0
        public async Task <ProjectInfoViewModel> CreateNewProject(User owner, string name, string mainLangName)
        {
            var proj = await _projectsRepository.CreateProject(owner, name, new Lang { Name = mainLangName });

            await _projectsRepository.SaveChanges();

            return(ProjectToViewModel(proj));
        }
        // POST: odata/Projects
        public async Task <IHttpActionResult> Post(Project project)
        {
            //Get access token to SharePoint
            string accessToken = await _tokenProvider.GetSharePointAccessToken();

            if (accessToken == null)
            {
                throw new UnauthorizedAccessException();
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Project newProject = await _repository.CreateProject(accessToken, project);

            return(Created(newProject));
        }