public RequirementEditorForm(PresentationModel presentationModel, Requirement requirement)
        {
            InitializeComponent();
            this._presentationModel = presentationModel;
            this._requirement = requirement;
            GetUserListByProject();

            _selectedHandler = new User();
            _selectedType = new NormalAttribute();
            _selectedPriority = new NormalAttribute();
            _selectedStatus = new NormalAttribute();

            _projectIds = new List<int>();
            _projectNames = new List<string>();
            _requireIds = new List<int>();
            _requireNames = new List<string>();
            _statusIds = new List<int>();
            _statusNames = new List<string>();
            _projectMemberArrayList = new List<int>();

            GetRequirementMethod(PRIORITY);
            GetRequirementMethod(REQUIREMENT);
            GetRequirementMethod(STATUS);
            CheckPriority();
            nameTextBox.Text = _requirement.Name;
            typeComboBox.SelectedItem = _requirement.Type.Name;
            versionLabel.Text = (Int32.Parse(_requirement.Version) + 1).ToString();
            priorityComboBox.SelectedItem = _requirement.Priority.Name;
            statusComboBox.SelectedItem = _requirement.Status.Name;
            handlerComboBox.Text = _requirement.Handler.Name;
            DescriptionRichTextBox.Text = _requirement.Description;
            MemoRichTextBox.Text = _requirement.Memo;
        }
        public RequirementEditorForm(PresentationModel presentationModel, Project project)
        {
            InitializeComponent();
            this._presentationModel = presentationModel;
            this._project = project;
            versionLabel.Text = "1";
            GetUserListByProject();

            _selectedHandler = new User();
            _selectedType = new NormalAttribute();
            _selectedPriority = new NormalAttribute();
            _selectedStatus = new NormalAttribute();

            _projectIds = new List<int>();
            _projectNames = new List<string>();
            _requireIds = new List<int>();
            _requireNames = new List<string>();
            _statusIds = new List<int>();
            _statusNames = new List<string>();
            _projectMemberArrayList = new List<int>();

            GetRequirementMethod(PRIORITY);
            GetRequirementMethod(REQUIREMENT);
            GetRequirementMethod(STATUS);
            CheckPriority();
        }
 /*private int _createdAt;
 private int _updatedAt;*/
 public Requirement(int id, int projectId, string name, User owner, User handler, string description, string version, string memo, NormalAttribute type, NormalAttribute priority, NormalAttribute status)
 {
     this._id = id;
     this._projectId = projectId;
     this._name = name;
     this._owner = owner;
     this._handler = handler;
     this._description = description;
     this._version = version;
     this._memo = memo;
     this._type = type;
     this._priority = priority;
     this._status = status;
 }
 public async Task<NormalAttribute[]> GetProjectPriorityType()
 {
     HttpClient client = new HttpClient();
     HttpResponseMessage response;
     var httpClient = new HttpClient();
     try
     {
         const string METHOD = "project/getProjectPriorityType/";
         string url = BASE_URL + METHOD;
         response = await httpClient.GetAsync(url);
         string content = await response.Content.ReadAsStringAsync();
         JArray array = JArray.Parse(content);
         NormalAttribute[] priorities = new NormalAttribute[array.Count];
         for(int i = 0; i < array.Count; i++)
         {
             JObject jObject = (JObject)array[i];
             NormalAttribute priority = new NormalAttribute();
             priority.ID = int.Parse(jObject["id"].ToString());
             priority.Name = jObject["name"].ToString();
             priorities[i] = priority;
         }
         return priorities;
     }
     catch (HttpRequestException)
     {
         throw new Exception("伺服器無回應");
     }
 }
 public async Task<Requirement[]> GetNoAssociatedRequirementByProjectId(int projectId)
 {
     HttpClient client = new HttpClient();
     HttpResponseMessage response;
     var httpClient = new HttpClient();
     try
     {
         const string METHOD = "requirement/getNoAssociatedRequirementByProjectId/";
         string url = BASE_URL + METHOD + projectId;
         response = await httpClient.GetAsync(url);
         string content = await response.Content.ReadAsStringAsync();
         if (response.StatusCode == HttpStatusCode.OK)
         {
             JObject json = JObject.Parse(content);
             string message = json["result"].ToString();
             JArray jsonArray = JArray.Parse(json["requirement_list"].ToString());
             if (message == "success")
             {
                 Requirement[] requirements = new Requirement[jsonArray.Count];
                 for (int i = 0; i < jsonArray.Count; i++)
                 {
                     JObject jObject = jsonArray[i] as JObject;
                     JObject jOwner = jObject["owner"] as JObject;
                     JObject jHandler = jObject["handler"] as JObject;
                     JObject jType = jObject["requirement_type"] as JObject;
                     JObject jPriority = jObject["priority_type"] as JObject;
                     JObject jStatus = jObject["status_type"] as JObject;
                     User owner = new User((int)jOwner["id"], jOwner["name"].ToString());
                     User handler = new User((int)jHandler["id"], jHandler["name"].ToString());
                     NormalAttribute type = new NormalAttribute((int)jType["id"], jType["name"].ToString());
                     NormalAttribute priority = new NormalAttribute((int)jPriority["id"], jPriority["name"].ToString());
                     NormalAttribute status = new NormalAttribute((int)jStatus["id"], jStatus["name"].ToString());
                     requirements[i] =  new Requirement((int)jObject["id"], projectId, jObject["name"].ToString(), owner, handler,
                         jObject["description"].ToString(), jObject["version"].ToString(), jObject["memo"].ToString(),
                         type, priority, status);
                 }
                 return requirements;
             }
             throw new Exception("取得失敗");
         }
         else if (response.StatusCode == HttpStatusCode.RequestTimeout)
         {
             throw new Exception("伺服器無回應");
         }
         else
         {
             throw new Exception("伺服器錯誤");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public NormalAttribute getRequirementAttribute(int id, string name)
 {
     NormalAttribute attribute = new NormalAttribute();
     attribute.ID = id;
     attribute.Name = name;
     return attribute;
 }