예제 #1
0
        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);
        }
예제 #2
0
 private static PartnerModel FromBranchToPartnerModel(Branch branch, CategoryModel[] categories)
 {
     return(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,
         Categories = branch.CategoryIds.Select(id => categories.FirstOrDefault(x => x.Id == id))
                      .Where(i => i != null).ToList(),
         WebAddresses = WebAddressMapper.MapToWebAddressModels(branch.WebAddresses)
     });
 }