Esempio n. 1
0
        public RecordListCollectionResponse ReadRecordLists()
        {
            RecordListCollectionResponse response = new RecordListCollectionResponse
            {
                Success = true,
                Message = "The lists were successfully returned!",
            };

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

                RecordListCollection recordListCollection = new RecordListCollection();
                recordListCollection.RecordLists = new List<RecordList>();

                foreach (IStorageEntity entity in storageEntities)
                {
                    recordListCollection.RecordLists.AddRange(entity.RecordLists.MapTo<RecordList>());
                }

                response.Object = recordListCollection;
            }
            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;
        }
Esempio n. 2
0
        public RecordListCollectionResponse ReadRecordLists(string entityName)
        {
            RecordListCollectionResponse response = new RecordListCollectionResponse();

            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 ReadRecordLists(entity);
        }
Esempio n. 3
0
        public RecordListCollectionResponse ReadRecordLists(Entity entity)
        {
            RecordListCollectionResponse response = new RecordListCollectionResponse
            {
                Success = true,
                Message = "The lists were successfully returned!",
            };

            try
            {
                RecordListCollection recordListCollection = new RecordListCollection();
                recordListCollection.RecordLists = entity.RecordLists;

                response.Object = recordListCollection;
            }
            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;
        }
Esempio n. 4
0
        public RecordListCollectionResponse ReadRecordLists()
        {
            RecordListCollectionResponse response = new RecordListCollectionResponse
            {
                Success = true,
                Message = "The lists 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;

                RecordListCollection recordListCollection = new RecordListCollection();
                recordListCollection.RecordLists = new List<RecordList>();

                foreach (Entity entity in entities)
                {
                    recordListCollection.RecordLists.AddRange(entity.RecordLists);
                }

                response.Object = recordListCollection;
            }
            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;
        }