private static Branch FromPartnerModelToBranch(PartnerModel partner, int numberOfContact)
        {
            Branch branch = new Branch();

            branch.PartnerId    = partner.Id;
            branch.Comment      = partner.Comment;
            branch.Image        = partner.Image;
            branch.Icon         = partner.Logo;
            branch.WebAddresses = WebAddressMapper.MapToWebAddresses(partner.WebAddresses);
            branch.Name         = SetValue(partner.Name_Ru, partner.Name_En);
            branch.Description  = SetValue(partner.Description_Ru, partner.Description_En);

            List <string> categoryIds = new List <string>();

            foreach (var category in partner.Categories)
            {
                categoryIds.Add(category.Id);
            }

            branch.CategoryIds = categoryIds;

            List <Discount> discounts = new List <Discount>();
            Discount        discount  = new Discount();

            discount.DiscountType = partner.SelectDiscount;
            var discountNames = SetValue(partner.Discount.ToString(CultureInfo.InvariantCulture), partner.Discount.ToString(CultureInfo.InvariantCulture));

            discount.Name = discountNames;
            discounts.Add(discount);
            branch.Discounts = discounts;

            branch.Address = ContactMapper.MapFromContactModelToAddress(partner.Contacts.ElementAt(numberOfContact));
            branch.Phones  = ContactMapper.MapFromContactModelToPhone(partner.Contacts.ElementAt(numberOfContact));
            branch.Id      = partner.Contacts.ElementAt(numberOfContact).Id;

            if (!string.IsNullOrEmpty(partner.Contacts.ElementAt(numberOfContact).Coordinates))
            {
                var stringCoords = partner.Contacts.ElementAt(numberOfContact).Coordinates.Split(CoordSeparator);
                var latitude     = double.Parse(stringCoords[0], CultureInfo.InvariantCulture);
                var longitude    = double.Parse(stringCoords[1], CultureInfo.InvariantCulture);
                branch.Location = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(new GeoJson2DGeographicCoordinates(longitude, latitude));
            }

            return(branch);
        }
Example #2
0
        private static Branch FromPartnerModelToBranch(PartnerModel partner, int numberOfContact)
        {
            var branch = new Branch
            {
                PartnerId    = partner.Id,
                Comment      = partner.Comment,
                Image        = partner.Image,
                Icon         = partner.Logo,
                WebAddresses = WebAddressMapper.MapToWebAddresses(partner.WebAddresses),
                Name         = SetValue(partner.Name_Ru, partner.Name_En),
                Description  = SetValue(partner.Description_Ru, partner.Description_En),
                CategoryIds  = partner.Categories.Select(i => i.Id),
                Discounts    = new List <Discount>
                {
                    new Discount
                    {
                        DiscountType = partner.SelectDiscount,
                        Name         = SetValue(partner.Discount.ToString(CultureInfo.InvariantCulture),
                                                partner.Discount.ToString(CultureInfo.InvariantCulture))
                    }
                },
                Address = ContactMapper.MapFromContactModelToAddress(partner.Contacts.ElementAt(numberOfContact)),
                Phones  = ContactMapper.MapFromContactModelToPhone(partner.Contacts.ElementAt(numberOfContact)),
                Id      = partner.Contacts.ElementAt(numberOfContact).Id
            };

            if (!string.IsNullOrEmpty(partner.Contacts.ElementAt(numberOfContact).Coordinates))
            {
                var stringCoords = partner.Contacts.ElementAt(numberOfContact).Coordinates.Split(CoordSeparator);
                var latitude     = double.Parse(stringCoords[0], CultureInfo.InvariantCulture);
                var longitude    = double.Parse(stringCoords[1], CultureInfo.InvariantCulture);
                branch.Location = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(new GeoJson2DGeographicCoordinates(longitude, latitude));
            }

            return(branch);
        }