private static PartnerModel FromBranchToPartnerModel(Branch branch, CategoryModel[] categories)
        {
            var partner = new PartnerModel
            {
                Name_Ru        = GetValue(branch.Name, Languages.Ru),
                Name_En        = GetValue(branch.Name, Languages.En),
                Description_Ru = GetValue(branch.Description, Languages.Ru),
                Description_En = GetValue(branch.Description, Languages.En),
                Comment        = branch.Comment,
                Image          = branch.Image,
                Logo           = branch.Icon,
                Id             = branch.PartnerId,
                Discount       = GetDiscount(branch.Discounts),
                SelectDiscount = branch.Discounts?.FirstOrDefault()?.DiscountType
            };

            var categoriesList = new List <CategoryModel>();

            foreach (var id in branch.CategoryIds)
            {
                var category = categories.FirstOrDefault(x => x.Id == id);
                if (category != null)
                {
                    categoriesList.Add(category);
                }
            }
            partner.Categories   = categoriesList;
            partner.WebAddresses = WebAddressMapper.MapToWebAddressModels(branch.WebAddresses);
            return(partner);
        }
        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);
        }