Ejemplo n.º 1
0
        public SamplesCollectionManager(string filePath, string userEmail = null)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(SamplesDetails));
            TextReader    reader       = new StreamReader(@"" + filePath);

            _samplesModel = (SamplesDetails)deserializer.Deserialize(reader);
            _samplesModel = GetChildElement(_samplesModel, userEmail);
            reader.Close();
            deserializer = null;
        }
Ejemplo n.º 2
0
        public SamplesDetails GetChildElement(SamplesDetails samplesDetails, string userEmail = null)
        {
            samplesDetails.Samples = new List <Sample>();
            var response = JsonConvert.DeserializeObject <List <APIResponse> >(new DashboardModel().GetDashboards(userEmail));

            foreach (var item in samplesDetails.Categories)
            {
                if (item.Id == 1)
                {
                    var sample = new Sample
                    {
                        Id            = 101,
                        Name          = "Create New",
                        Description   = "",
                        CategoryId    = 1,
                        DashboardPath = "",
                        Title         = "Bold BI | Create"
                    };
                    samplesDetails.Samples.Add(sample);
                }
                if (response != null && response.Count > 0)
                {
                    if (item.Id == 1)
                    {
                        var randomId = 1000;
                        foreach (var list in response)
                        {
                            var sample = new Sample
                            {
                                Id                   = randomId,
                                Name                 = list.Name,
                                Description          = list.Description,
                                CategoryId           = 1,
                                DashboardPath        = "/" + list.CategoryName + "/" + list.Name,
                                Title                = "Bold BI | " + list.Name,
                                CreatedById          = list.CreatedById,
                                ItemID               = list.Id,
                                IsPublic             = list.IsPublic,
                                CanRead              = list.CanRead,
                                CanDelete            = list.CanDelete,
                                CanWrite             = list.CanWrite,
                                CategoryName         = list.CategoryName,
                                CreatedByDisplayName = list.CreatedByDisplayName,
                                ModifiedDate         = list.ModifiedDate
                            };

                            samplesDetails.Samples.Add(sample);
                            randomId = randomId + 1;
                        }
                    }
                }
            }

            return(samplesDetails);
        }