Exemple #1
0
        public static CompanyUpdateOutPutViewModel Map(CompanyUpdateOutPutDtoModel dtoModel)
        {
            var viewModel = new CompanyUpdateOutPutViewModel
            {
                CompanyId    = dtoModel.CompanyId,
                CompanyName  = dtoModel.CompanyName,
                TownName     = dtoModel.TownName,
                Address      = dtoModel.Address,
                Phone        = dtoModel.Phone,
                CategoryName = dtoModel.CategoryName,
                Towns        = dtoModel.Towns,
                Categories   = dtoModel.Categories
            };

            return(viewModel);
        }
        public static CompanyUpdateOutPutDtoModel Map(Company company, IList <string> towns, IList <string> categories)
        {
            var townIndex     = towns.IndexOf(company.Town.Name);
            var categoryIndex = categories.IndexOf(company.UseFullCategory.Name);

            towns.RemoveAt(townIndex);
            categories.RemoveAt(categoryIndex);

            var dtoModel = new CompanyUpdateOutPutDtoModel
            {
                CompanyId    = company.Id,
                CompanyName  = company.Name,
                TownName     = company.Town.Name,
                Address      = company.Address,
                Phone        = company.Phone,
                CategoryName = company.UseFullCategory.Name,
                Towns        = towns,
                Categories   = categories
            };

            return(dtoModel);
        }