Beispiel #1
0
        public async Task <ActionResult <ProjectResponse> > PostProject(ProjectRequest project)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var projects = await projectClass.CreateProject(project);

                    if (projects == null)
                    {
                        projectResponse = new ProjectResponse
                        {
                            StatusCode = 400,
                            Message    = "Fail to create project"
                        };

                        return(BadRequest(projectResponse));
                    }
                    else
                    {
                        projectResponse = new ProjectResponse
                        {
                            StatusCode   = 200,
                            Message      = "Successfully Created",
                            ResponseData = projects
                        };
                        return(Ok(projectResponse));
                    }
                }
                else
                {
                    projectResponse = new ProjectResponse
                    {
                        StatusCode = 400,
                        Message    = "Invalid input ",
                    };
                    return(BadRequest(projectResponse));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }