public IHttpActionResult GetTableProperties(long tableId)
        {
            try
            {
                var connectionString = Request.Headers.GetValues("connectionString").FirstOrDefault();

                HttpRequires.IsNotNull(connectionString, "Ivnalid Connection");
                HttpRequires.IsTrue(tableId >= 0, "Invalid Table Id");

                var response = _propertyDal.RetrieveByTableId(tableId, connectionString);

                HttpAssert.Success(response);
                HttpAssert.NotNull(response, "Unable to find property results for table");
                return(Ok(response.Result));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #2
0
        public void NotNull_Invalid()
        {
            //Arrange
            var dalResp = new ResponseModel <User>
            {
                Result   = null,
                HasError = false
            };

            //Act
            HttpAssert.NotNull(dalResp, "");
        }
Example #3
0
        public void NotNull_Valid()
        {
            //Arrange
            var dalResp = new ResponseModel <User>
            {
                HasError = false,
                Result   = new User()
            };

            //Act
            HttpAssert.NotNull(dalResp, "");
        }
Example #4
0
        public void NotNull_Valid()
        {
            //Arrange
            var dalResp = new DalResponseModel <ColumnModel>
            {
                HasError = false,
                Result   = new ColumnModel()
            };

            //Act
            HttpAssert.NotNull(dalResp, "");
        }
        /// <summary>
        /// Method to get the properties for a table (includes the properties for the
        /// table's columns)
        /// </summary>
        /// <param name="tableId"></param>
        /// <returns></returns>
        private List <ExtendedPropertyModel> GetProperties(long tableId)
        {
            var connectionString = Request.Headers["connectionString"].FirstOrDefault();

            HttpRequires.IsNotNull(connectionString, "Ivnalid Connection");
            HttpRequires.IsTrue(tableId >= 0, "Invalid Table Id");

            var dalResp = _propertyDal.RetrieveByTableId(tableId, connectionString);

            HttpAssert.Success(dalResp);
            HttpAssert.NotNull(dalResp, "Unable to find property results for table");

            return(dalResp.Result.ToList());
        }
        /// <summary>
        /// Method to get a collection of columns for the user's selected table.
        /// </summary>
        /// <param name="tableId"></param>
        /// <returns></returns>
        private List <ColumnModel> GetColumns(long tableId)
        {
            var connectionString = Request.Headers["connectionString"].FirstOrDefault();

            HttpRequires.IsNotNull(connectionString, "Invalid Connection");
            HttpRequires.IsTrue(tableId > 0, "Invalid Table Id");

            //var dalResp = ColumnDal.GetColumns(tableId, connectionString);
            var dalResp = _columnDal.GetColumns(tableId, connectionString);

            HttpAssert.Success(dalResp);
            HttpAssert.NotNull(dalResp, "Unable to find column results for table");
            return(dalResp.Result.ToList());
        }
        /// <summary>
        /// Method to get a collection of tables in the database selected by the user.
        /// </summary>
        /// <returns></returns>
        private List <TableModel> GetTables()
        {
            var connectionString = Request.Headers["connectionString"].FirstOrDefault();

            //connectionString = connectionString.Replace("|DataDirectory|", "..\\..\\SqlServerDocumenterUtility\\App_Data");

            HttpRequires.IsNotNull(connectionString, "Invalid connection");

            //var dalResp = TableDal.GetTables(connectionString);
            var dalResp = _tableDal.GetTables(connectionString);

            HttpAssert.Success(dalResp);
            HttpAssert.NotNull(dalResp, "Unable to find results for table");

            return(dalResp.Result.ToList());
        }
Example #8
0
        public IHttpActionResult GetTables()
        {
            try
            {
                var connectionString = Request.Headers.GetValues("connectionString").FirstOrDefault();

                HttpRequires.IsNotNull(connectionString, "Invalid connection");

                var response = _tableDal.GetTables(connectionString);

                HttpAssert.Success(response);
                HttpAssert.NotNull(response, "Unable to find results for table");
                return(Ok(response.Result));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public IHttpActionResult GetAll()
        {
            try
            {
                var response = _institutionRepo.FindAll();

                HttpAssert.Success(response);
                HttpAssert.NotNull(response, "Unable to find institutions");

                return(Ok(response.Result.ToList()));
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Write(ex);
                }
                return(InternalServerError());
            }
        }
Example #10
0
        public IHttpActionResult GetResidentShifts(int residentId)
        {
            try
            {
                HttpRequires.IsTrue(residentId > 0, "A valid resident identifier is required");

                var response = _residentRepo.FindShiftsByResidentId(residentId);

                HttpAssert.Success(response);
                HttpAssert.NotNull(response, String.Format("Unable to find shifts for resident with id [{0}]", residentId));

                return(Ok(response.Result));
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Write(ex);
                }
                return(InternalServerError());
            }
        }
        public IHttpActionResult Get(int institutionId)
        {
            try
            {
                HttpRequires.IsTrue(institutionId > 0, "A valid institution identifier is required");

                var response = _institutionRepo.Find(institutionId);

                HttpAssert.Success(response);
                HttpAssert.NotNull(response, String.Format("Unable to find an institution with id [{0}]", institutionId));

                return(Ok(response.Result));
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Write(ex);
                }
                return(InternalServerError());
            }
        }
        public IHttpActionResult GetInstitutionResidents(int institutionId)
        {
            try
            {
                HttpRequires.IsTrue(institutionId > 0, "A valid instituion identifier is required");

                var response = _institutionRepo.FindResidentsByInstitutionId(institutionId);

                HttpAssert.Success(response);
                HttpAssert.NotNull(response, "Unable to find residents for the institution");

                return(Ok(response.Result));
            }
            catch (Exception ex)
            {
                //TODO: Server side logging/notification here
                if (_logger != null)
                {
                    _logger.Write(ex);
                }
                return(InternalServerError());
            }
        }