예제 #1
0
        public HttpResponseMessage CreateNewProject(Project project)
        {
            HttpResponseMessage Response = null;

            try
            {
                if (project != null)
                {
                    Project existingInstance = ProjectRepo.GetExistingProject(project.project_name, project.client_id);
                    if (existingInstance == null)
                    {
                        ProjectRepo.CreateNewProject(project);
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Project added successfully", "Project added successfully"));
                    }
                    else
                    {
                        Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_203", "Project ID already exists", "Project ID already exists"));
                    }
                }
                else
                {
                    Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Please check the Json input", "Please check the Json input"));
                }
            }
            catch (DbEntityValidationException DBexception)
            {
                Debug.WriteLine(DBexception.Message);
                Debug.WriteLine(DBexception.GetBaseException());
                Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Some Mandatory fields are missing", DBexception.Message));
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                Debug.WriteLine(exception.GetBaseException());
                Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message));
            }
            return(Response);
        }