public IHttpActionResult AddProject(AddNewProjectModel newProject)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            else
            {
                var project = new Project
                {
                    Name             = newProject.Name,
                    Description      = newProject.Description,
                    ClientId         = newProject.ClientId,
                    ProjectLeaderId  = newProject.ProjectLeaderId,
                    ProjectManagerId = newProject.ProjectManagerId
                };

                _context.Projects.Add(project);
                _context.SaveChanges();

                return(Ok(project));
            }
        }
Пример #2
0
        public IHttpActionResult AddIssue(AddIssueModel newIssue)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            else
            {
                var issue = new Issue
                {
                    Title         = newIssue.Title,
                    Description   = newIssue.Description,
                    CriticalLevel = newIssue.CriticalLevel,
                    DeadLine      = newIssue.DeadLine,
                    ProjectId     = newIssue.ProjectId
                };

                _context.Issues.Add(issue);
                _context.SaveChanges();

                return(Ok(issue));
            }
        }