Beispiel #1
0
        public IHttpActionResult SaveResidentShift(int residentId, [FromBody] ResidentShiftModel shift)
        {
            try
            {
                HttpRequires.IsNotNull(shift, "Shift Data Required");

                var response = _residentSvc.SaveShift(shift);

                HttpAssert.Success(response);

                // NOTE: THIS SECTION CONTAINS CHANGES ADDED AFTER THE
                //    DEADLINE, TO RESOLVE BUG PERSISTING TIME ENTRIES
                return(Ok(new
                {
                    Shift = response.Result.Item1,
                    Shifts = response.Result.Item2
                }));
            }
            catch (ShiftConflictException ex)
            {
                return(this.BadRequest(new
                {
                    Type = "ShiftConflict",
                    Data = ex.Conflicts
                }));
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Write(ex);
                }
                return(InternalServerError());
            }
        }
        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));
            }
        }
Beispiel #3
0
        public Patient UpdateFirstName(int id, [FromBody] string firstName)
        {
            var response = this.PatientService.UpdateFirstName(id, firstName, "");

            HttpAssert.Success(response);

            return(response.Result);
        }
Beispiel #4
0
        public Patient Update(Patient patient)
        {
            var response = this.PatientService.Save(patient, "");

            HttpAssert.Success(response);

            return(response.Result);
        }
Beispiel #5
0
        public IList <Patient> Find(PatientSearchCriteria criteria)
        {
            var response = this.PatientService.Find(criteria);

            HttpAssert.Success(response);

            return(response.Result);
        }
Beispiel #6
0
        public Patient Get(int id)
        {
            var response = this.PatientService.Get(id);

            HttpAssert.Success(response);
            HttpAssert.IsNotNull(response);

            return(response.Result);
        }
Beispiel #7
0
        public void Success_Valid()
        {
            //Arrange
            var response = new ResponseModel <bool> {
                HasError = false
            };

            //Act
            HttpAssert.Success(response);
        }
        /// <summary>
        /// Method to add an extended property to a table or table column
        /// </summary>
        /// <param name="model"></param>
        private void Add(ExtendedPropertyModel model)
        {
            var connectionString = Request.Headers["connectionString"].FirstOrDefault();

            HttpRequires.IsNotNull(connectionString, "Invalid Connection");
            HttpRequires.IsNotNull(model, "Invalid Properties");

            var response = _propertyDal.AddProperty(model, connectionString);

            HttpAssert.Success(response);
        }
Beispiel #9
0
        public void Success_InValid()
        {
            //Arrange
            var dalResp = new DalResponseModel <bool> {
                HasError  = true,
                Exception = new NullReferenceException()
            };

            //Act
            HttpAssert.Success(dalResp);
        }
Beispiel #10
0
        public PatientTrackingReport GetTracking(int id, DateTime?startDate, DateTime?endDate)
        {
            HttpRequires.IsNotNull(startDate, "Start Date is required.");
            HttpRequires.IsNotNull(endDate, "End Date is required.");
            HttpRequires.IsTrue(endDate >= startDate, "End Date must be greater than or equal to the Start Date");

            var response = PatientService.GetTrackingReport(id, startDate.Value, endDate.Value);

            HttpAssert.Success(response);
            HttpAssert.IsNotNull(response);

            return(response.Result);
        }
        /// <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 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 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());
        }
Beispiel #14
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));
            }
        }
        /// <summary>
        /// Method to update an extended property of a table or column
        /// </summary>
        /// <param name="model"></param>
        private void Update(ExtendedPropertyModel model)
        {
            var connectionString = Request.Headers["connectionString"].FirstOrDefault();

            HttpRequires.IsNotNull(connectionString, "Invalid Connection");
            HttpRequires.IsNotNull(model, "Invalid Properties");

            //Using the sql server system procedures I had (for add and delete). Instead of an in
            // place update, the process is to first delete the existing property, and then add
            // the new values. To avoid a situation where the delete succeeds but the add fails,
            // we use a transaction scope.
            using (var scope = new TransactionScope())
            {
                var deleteResp = _propertyDal.DeleteProperty(model, connectionString);
                var addResp    = _propertyDal.AddProperty(model, connectionString);
                HttpAssert.Success(deleteResp);
                HttpAssert.Success(addResp);
                scope.Complete();
            }
        }
        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());
            }
        }
Beispiel #17
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());
            }
        }
        public IHttpActionResult AddProperty([FromBody] ExtendedPropertyModel propertyModel)
        {
            try
            {
                var connectionString = Request.Headers.GetValues("connectionString").FirstOrDefault();

                HttpRequires.IsNotNull(connectionString, "Invalid Connection");
                HttpRequires.IsNotNull(propertyModel, "Invalid Properties");
                ValidatePropertyModel(propertyModel);

                var response = _propertyDal.AddProperty(propertyModel, connectionString);

                HttpAssert.Success(response);
                return(Ok());
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public IHttpActionResult UpdateProperty([FromBody] ExtendedPropertyModel propertyModel)
        {
            try
            {
                var connectionString = Request.Headers.GetValues("connectionString").FirstOrDefault();

                HttpRequires.IsNotNull(connectionString, "Invalid Connection");
                HttpRequires.IsNotNull(propertyModel, "Invalid Properties");
                ValidatePropertyModel(propertyModel);

                DalResponseModel deletionResponse, addResponse;

                //Using the sql server system procedures I had (for add and delete). Instead of an in
                // place update, the process is to first delete the existing property, and then add
                // the new values. To avoid a situation where the delete succeeds but the add fails,
                // we use a transaction scope.
                using (var scope = new TransactionScope())
                {
                    deletionResponse = _propertyDal.DeleteProperty(propertyModel, connectionString);
                    addResponse      = _propertyDal.AddProperty(propertyModel, connectionString);
                    HttpAssert.Success(deletionResponse);
                    HttpAssert.Success(addResponse);
                    scope.Complete();
                }

                return(Ok());
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }