Example #1
0
        private RecordViewCollectionResponse ReadRecordViews(Entity entity)
        {
            RecordViewCollectionResponse response = new RecordViewCollectionResponse
            {
                Success = true,
                Message = "The record views were successfully returned!",
            };

            try
            {
                RecordViewCollection recordViewList = new RecordViewCollection();
                recordViewList.RecordViews = entity.RecordViews;

                response.Object = recordViewList;
            }
            catch (Exception e)
            {
                response.Timestamp = DateTime.UtcNow;
                response.Success = false;
            #if DEBUG
                response.Message = e.Message + e.StackTrace;
            #else
                response.Message = "An internal error occurred!";
            #endif
                return response;
            }

            response.Timestamp = DateTime.Now;

            return response;
        }
Example #2
0
        public RecordViewCollectionResponse ReadRecordViews(string entityName)
        {
            RecordViewCollectionResponse response = new RecordViewCollectionResponse();

            EntityResponse entityResponse = ReadEntity(entityName);

            if (!entityResponse.Success)
            {
                response.Timestamp = DateTime.UtcNow;
                response.Success = false;
                response.Message = entityResponse.Message;
                return response;
            }
            else if (entityResponse.Object == null)
            {
                response.Timestamp = DateTime.UtcNow;
                response.Success = false;
                response.Message = "Entity with such name does not exist!";
                return response;
            }

            Entity entity = entityResponse.Object;

            return ReadRecordViews(entity);
        }
Example #3
0
        public RecordViewCollectionResponse ReadRecordViews()
        {
            RecordViewCollectionResponse response = new RecordViewCollectionResponse
            {
                Success = true,
                Message = "The record views were successfully returned!",
            };

            try
            {
                List<IStorageEntity> storageEntities = EntityRepository.Read();

                RecordViewCollection recordViewList = new RecordViewCollection();
                recordViewList.RecordViews = new List<RecordView>();

                foreach (IStorageEntity entity in storageEntities)
                {
                    recordViewList.RecordViews.AddRange(entity.RecordViews.MapTo<RecordView>());
                }

                response.Object = recordViewList;
            }
            catch (Exception e)
            {
                response.Timestamp = DateTime.UtcNow;
                response.Success = false;
            #if DEBUG
                response.Message = e.Message + e.StackTrace;
            #else
                response.Message = "An internal error occurred!";
            #endif
                return response;
            }

            response.Timestamp = DateTime.Now;

            return response;
        }
Example #4
0
        public RecordViewCollectionResponse ReadRecordViews()
        {
            RecordViewCollectionResponse response = new RecordViewCollectionResponse
            {
                Success = true,
                Message = "The record views were successfully returned!",
            };

            try
            {
                var entitiesResponse = ReadEntities();

                if (!entitiesResponse.Success)
                {
                    response.Timestamp = DateTime.UtcNow;
                    response.Success = false;
                    response.Message = entitiesResponse.Message;
                    return response;
                }
                else if (entitiesResponse.Object == null)
                {
                    response.Timestamp = DateTime.UtcNow;
                    response.Success = false;
                    response.Message = "There is no entities into database!";
                    return response;
                }

                List<Entity> entities = entitiesResponse.Object;

                RecordViewCollection recordViewList = new RecordViewCollection();
                recordViewList.RecordViews = new List<RecordView>();

                foreach (Entity entity in entities)
                {
                    recordViewList.RecordViews.AddRange(entity.RecordViews);
                }

                response.Object = recordViewList;
            }
            catch (Exception e)
            {
                response.Timestamp = DateTime.UtcNow;
                response.Success = false;
            #if DEBUG
                response.Message = e.Message + e.StackTrace;
            #else
                response.Message = "An internal error occurred!";
            #endif
                return response;
            }

            response.Timestamp = DateTime.Now;

            return response;
        }