示例#1
0
        public async Task <ActionResult <ProjectDto> > Create([Required] ProjectDto project)
        {
            var myProj = new Project {
                Description = project.Description, Title = project.Title, CreationDate = DateTimeOffset.Now
            };
            await _projectDatabase.Add(myProj);

            return(ProjectDto.FromProject(myProj));
        }
示例#2
0
        public async Task <bool> AddProjectAsync(Project project)
        {
            var proj = await ApiAccess.AddNewProject(ProjectDto.FromProject(project));

            if (proj.Id == null || proj.CreationDate == null)
            {
                return(false);
            }
            project.Id           = proj.Id.Value;
            project.CreationDate = proj.CreationDate.Value;
            return(true);
        }
示例#3
0
        public async Task <ActionResult <ProjectDto> > Get([Required] int id)
        {
            var proj = await _projectDatabase.FindOrDefault(id);

            if (proj == null)
            {
                return(NotFound());
            }
            else
            {
                return(ProjectDto.FromProject(proj));
            }
        }
示例#4
0
 public ActionResult <List <ProjectDto> > Get()
 {
     return(_projectDatabase.GetAll().Select(d => ProjectDto.FromProject(d)).ToList());
 }