コード例 #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
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Project.CreationDate = DateTime.Now;
            await _context.Add(Project);

            return(RedirectToPage("./Index"));
        }