private static ICollection <StatSalesType> GetStatSalesDataFromString(string xml, DateTime date, bool isGroupNumber, ICollection <GroupType> groups) { var xmlData = Serializator.CreateFromXMLString <XmlStructure>(xml); var result = new List <StatSalesType>(); if (xmlData != null && xmlData.Checks != null) { foreach (var check in xmlData.Checks) { result.AddRange( check.Products.Select(product => new StatSalesType( product.CustumerId, date, groups == null ? product.Name : groups.First(g => g.Id == product.GroupId).SubGroups.First(s => s.Id == product.SubgroupId).Name, check.BarCode, product.Price, product.Qty, 0, product.Tva, product.SumDiscount, product.Total, isGroupNumber ? product.GroupId : product.SubgroupId))); } } return(result.ToArray()); }
public static ICollection <ProductType> GetProducts(string xml) { var products = Serializator.CreateFromXMLString <ProductDatas>(xml); var result = products.Products.Select(product => new ProductType(product.Id, product.Name, product.BarCode)).ToList(); return(result.OrderBy(p => p.Name).ToArray()); }
public static ICollection <GroupType> GetGroups(string xml) { var palettes = Serializator.CreateFromXMLString <PaletteDatas>(xml); var result = new List <GroupType>(); foreach (var palette in palettes.Palettes) { var group = new GroupType(palette.Group.Id, palette.Group.Name, palette.SubGroups[0].Id, palette.SubGroups[0].Name); for (var i = 1; i < palette.SubGroups.Length; i++) { var subGroup = new SubGroupType(palette.SubGroups[i].Id, palette.SubGroups[i].Name, palette.Group.Id); group.SubGroups.Add(subGroup); } result.Add(group); } return(result.OrderBy(g => g.Name).ToArray()); }