public IHttpActionResult UpdateProject(StudyViewModel model, string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                return(BadRequest("Empty id"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid data"));
            }

            var studyProject = StudyManager.Instance.GetStudyProject(id);

            if (studyProject == null)
            {
                return(NotFound());
            }

            var study = StudyManager.Instance.GetStudy(studyProject, model.TreeId);

            if (study == null)
            {
                return(NotFound());
            }

            int    studyYear;
            string trimmedStudyYear = model.Column;

            trimmedStudyYear = trimmedStudyYear.Replace("class_", String.Empty);

            if (!int.TryParse(trimmedStudyYear, out studyYear))
            {
                return(BadRequest("Study year is not numeric"));
            }

            int    creditPoints;
            string creditPointsText = model.Value;

            creditPointsText = String.IsNullOrEmpty(creditPointsText) ? "0" : creditPointsText;

            if (!int.TryParse(creditPointsText, out creditPoints))
            {
                return(BadRequest("Credit points are  not numeric"));
            }

            if (studyYear >= 0 && studyYear <= 2)
            {
                study.CreditPoints[studyYear] = creditPoints;
            }
            else
            {
                return(BadRequest("Study year is invalid"));
            }

            var check = StudyRuleManager.CheckStudyProject(studyProject);

            return(Ok(check));
        }
        public IHttpActionResult GetProject(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                return(BadRequest("Empty id"));
            }

            var studyProject = StudyManager.Instance.GetStudyProject(id);

            if (studyProject == null)
            {
                return(NotFound());
            }

            var check = StudyRuleManager.CheckStudyProject(studyProject);

            return(Ok(new StudyProjectViewModel
            {
                Project = studyProject,
                Messages = check
            }));
        }