public DiscountData(DeserializeBranchItem branchItem) : this()
        {
            _documentId = branchItem.Id;
            _partnerId = branchItem.PartnerId;

            foreach (var item in branchItem.Name)
                SetName(item.Lan, item.LocText);

            foreach (var item in branchItem.Description)
                SetDescription(item.Lan, item.LocText);
            
            if (branchItem.Discounts.Count > 0 && branchItem.Discounts[0].Name.Count > 0)
                _discountPercent = branchItem.Discounts[0].Name[0].LocText;
           
            foreach (var item in branchItem.Categories)
            {
                var categorie = new CategorieData();
                int typeCode = 0;
                int.TryParse (item.Type, out typeCode);
                categorie.TypeCode = typeCode;
                foreach (var itemName in item.Name)
                    categorie.SetName(itemName.Lan, itemName.LocText);
                _categorieList.Add(categorie);
            }

            _urlAddress = branchItem.Url;

            _icon = branchItem.Icon;
        }
        public MapPinData(DeserializeBranchItem deserializeBranch) : this()
        {
            NumberFormatInfo format = new NumberFormatInfo();
            format.NumberGroupSeparator = ",";
            format.NumberDecimalSeparator = ".";

            foreach (var item in deserializeBranch.Categories)
            {
                var categorie = new CategorieData();
                int typeCode = 0;
                int.TryParse(item.Type, out typeCode);
                categorie.TypeCode = typeCode;
                foreach (var itemName in item.Name)
                    categorie.SetName(itemName.Lan, itemName.LocText);
                _categorieList.Add(categorie);
            }

            if (_categorieList.Count > 0)
                _primaryCategory = _categorieList[0];
            else
                _primaryCategory = new CategorieData { TypeCode = -1 };

            try
            {
                _discount = deserializeBranch.Discounts[0].Name[0].LocText;
            }
            catch
            {
                _discount = "0";
            }

            _latitude = Double.Parse(deserializeBranch.Location.Coordinates.Latitude, format);
            _longitude = Double.Parse(deserializeBranch.Location.Coordinates.Longitude, format);
            _id = deserializeBranch.Id;
            _partnerId = deserializeBranch.PartnerId;

            foreach (var item in deserializeBranch.Name)
                SetName(item.Lan, item.LocText);
        }
        public async Task UpdateDiscount(DeserializeBranchItem branchItem)
        {
            NumberFormatInfo format = new NumberFormatInfo();
            format.NumberGroupSeparator = ",";
            format.NumberDecimalSeparator = ".";

            Discount discountDBData = database.Table<Discount>().FirstOrDefault(x => x.DocumentId == branchItem.PartnerId);
            if (discountDBData == null)
                return;

            database.BeginTransaction();

            if (!String.IsNullOrWhiteSpace(branchItem.Image))
            {
                string imgFileName = discountDBData.DocumentId + PostfixImgFileName;
                await SaveImage(imgFileName, branchItem.Image);
                discountDBData.ImageFileName = imgFileName;
                discountDBData.IsFullDescription = true;
                database.Update(discountDBData);

                var discount = AppData.Discount.DiscountCollection.FirstOrDefault<DiscountData>(x => x.DocumentId == discountDBData.DocumentId);
                if (discount != null)
                    discount.IsFullDescription = true;
            }

            Contact contactDBData = database.Table<Contact>().FirstOrDefault(x => x.DiscountId == discountDBData.Id && x.DocumentId == branchItem.Id);

            if (contactDBData == null)
            {
                contactDBData = new Contact();
                database.Insert(contactDBData);
            }

            contactDBData.DiscountId = discountDBData.Id;
            contactDBData.DocumentId = branchItem.Id;
            contactDBData.Latitude = Double.Parse(branchItem.Location.Coordinates.Latitude, format);
            contactDBData.Longitude = Double.Parse(branchItem.Location.Coordinates.Longitude, format);

            if (branchItem.Address != null)
                foreach (var address in branchItem.Address)
                {
                    LangString langStringRec = new LangString { LanguageCode = address.Lan.ToUpper(), Text = address.LocText };
                    database.Insert(langStringRec);

                    DiscountsStrings discountsStringsRec = new DiscountsStrings { Appointment = StrAppointmentAddress, OwnerId = contactDBData.Id, LangStringId = langStringRec.Id };
                    database.Insert(discountsStringsRec);
                }

            if (branchItem.Phones != null)
            {
                if (branchItem.Phones.Count > 0)
                    contactDBData.Phone1 = branchItem.Phones[0].Number;

                if (branchItem.Phones.Count > 1)
                    contactDBData.Phone2 = branchItem.Phones[1].Number;
            }

            database.Update(contactDBData);

            database.Commit();
        }