Example #1
0
        public async Task <IHttpActionResult> Get(string collegeName, bool includeRoomAndBoard = true)
        {
            if (string.IsNullOrEmpty(collegeName))
            {
                return(BadRequest("Error: College name is required"));
            }

            var college = await _collegeRepo.GetCollegeByName(collegeName);

            if (college == null)
            {
                // NOTE: I would normally use NotFound() but the requirments state an error message must be returned
                return(BadRequest("Error: College not found"));
            }

            decimal annualCollegeCost = _tuitionCalculator.CalculateAnnualCost(college, includeRoomAndBoard);

            return(Ok(annualCollegeCost));
        }