コード例 #1
0
        public string Insert(Project project)
        {
            if (String.IsNullOrEmpty(project.Name))
            {
                return "bad_request";
            }
            else if (!ProjectsRep.CheckProjectNameUniqueness(project.Name))
            {
                return "conflict";
            }

            return ProjectsRep.Insert(project).ToString();
        }
コード例 #2
0
        public long Post(Project project)
        {
            var returnedValue = projectsBusiness.Insert(project);
            long id = 0;
            bool isNum = long.TryParse(returnedValue, out id);
            if (!isNum)
            {
                if (returnedValue == "bad_request")
                {
                    throw new ApiException(HttpStatusCode.BadRequest, "Supplied parameters in the request are malformed");
                }
                else
                {
                    throw new ApiException(HttpStatusCode.Conflict, "There is already a same project wih supplied information"); //if email is not unique
                }
            }

            return id; //returns Success[200]
        }