Наследование: DomainObject
Пример #1
0
 /// <summary>
 /// Конвертационные функции
 /// </summary>
 private Product ConvertFromProductViewModelToProduct(ProductViewModel c)
 {
     Product product = new Product()
     {
         Id = c.Id,
         Name = c.Name,
         Description = c.Description,
         CreatedDate = c.CreatedDate,
         UpdatedDate = c.UpdatedDate,
         Active = c.Active,
         Type = c.Type,
         PartnerId = c.PartnerId,
         Teacher = c.Teacher,
         SeatsCount = c.SeatsCount,
         AssignedUserId = c.AssignedUserId,
         Location = c.Location,
         Image = (c.Image == null || c.Image.Length == 0) ? null : c.Image
     };
     return product;
 }
Пример #2
0
        private ProductWithCategorysViewModel ConvertFromProductToProductWithCategorysViewModel(Product product)
        {
            ProductWithCategorysViewModel productView = new ProductWithCategorysViewModel();
            productView.Categorys = new List<CategoryViewModel>();

            foreach (Category c in product.Categories)
            {
                productView.Categorys.Add(ConvertFromCategoryToCategoryViewModel(c));
            }

            productView.Id = product.Id;
            productView.Name = product.Name;
            productView.Description = product.Description;
            productView.CreatedDate = product.CreatedDate;
            productView.UpdatedDate = product.UpdatedDate;
            productView.Active = product.Active;
            productView.Type = product.Type;
            productView.PartnerId = product.PartnerId;
            productView.Teacher = product.Teacher;
            productView.SeatsCount = product.SeatsCount ?? null;
            productView.AssignedUserId = product.AssignedUserId ?? null;
            productView.Location = product.Location;
            productView.Image = (product.Image == null || product.Image.Length == 0) ? null : product.Image;
            productView.ManagerName = (product.User != null) ? product.User.Login : "******";
            productView.PartnerName = (product.Partner != null) ? product.Partner.Name : "Отсутствует";
            productView.ManagerName = (product.User != null) ? product.User.Login : "******";

            return productView;
        }
Пример #3
0
        private ProductWithAllCategorysViewModel ConvertFromProductToProductWithAllCategorysViewModel(Product c)
        {
            ProductWithCategorysViewModel productWithCategorys = ConvertFromProductToProductWithCategorysViewModel(c);
            ProductWithAllCategorysViewModel productWithAllCategorys = new ProductWithAllCategorysViewModel();

            productWithAllCategorys.Categorys = productWithCategorys.Categorys;
            productWithAllCategorys.Id = productWithCategorys.Id;
            productWithAllCategorys.Name = productWithCategorys.Name;
            productWithAllCategorys.Description = productWithCategorys.Description;
            productWithAllCategorys.CreatedDate = productWithCategorys.CreatedDate;
            productWithAllCategorys.UpdatedDate = productWithCategorys.UpdatedDate;
            productWithAllCategorys.Active = productWithCategorys.Active;
            productWithAllCategorys.Type = productWithCategorys.Type;
            productWithAllCategorys.PartnerId = productWithCategorys.PartnerId;
            productWithAllCategorys.Teacher = productWithCategorys.Teacher;
            productWithAllCategorys.SeatsCount = productWithCategorys.SeatsCount ?? null;
            productWithAllCategorys.AssignedUserId = productWithCategorys.AssignedUserId ?? null;
            productWithAllCategorys.Location = productWithCategorys.Location;
            productWithAllCategorys.Image = (productWithCategorys.Image == null || productWithCategorys.Image.Length == 0) ? null : productWithCategorys.Image;

            productWithAllCategorys.ManagerName = productWithCategorys.ManagerName;
            productWithAllCategorys.PartnerName = productWithCategorys.PartnerName;

            var categorysList = categoryRepository.Get().Select(ConvertFromCategoryToCategoryViewModel);
            productWithAllCategorys.AllCategorys = categorysList.ToList();

            return productWithAllCategorys;
        }
Пример #4
0
        private ProductViewModelForWebApi ConvertFromProductToProductViewModel_WebApi(Product product)
        {
            ProductViewModelForWebApi productView = new ProductViewModelForWebApi();

            productView.CategoriesNames = new List<String>();

            foreach (Category c in product.Categories)
            {
                productView.CategoriesNames.Add(c.Name);
                productView.CategoriesNamesString += c.Name + " ; ";
            }

            productView.Id = product.Id;
            productView.Name = product.Name;
            productView.Description = product.Description;
            productView.CreatedDate = product.CreatedDate;
            productView.UpdatedDate = product.UpdatedDate;
            productView.Active = product.Active;
            productView.Type = product.Type;
            productView.PartnerId = product.PartnerId;
            productView.Teacher = product.Teacher;
            productView.SeatsCount = product.SeatsCount ?? null;
            productView.AssignedUserId = product.AssignedUserId ?? null;
            productView.Location = product.Location;
            productView.Image = (product.Image == null || product.Image.Length == 0) ? null : product.Image;

            productView.PartnerName = (product.Partner != null) ? product.Partner.Name : "Отсутствует";
            productView.ManagerName = (product.User != null) ? product.User.Login : "******";

            switch (productView.Type)
            {
                case 1: productView.TypeName = "Курс"; break;
                case 2: productView.TypeName = "Серия лекций"; break;
                case 3: productView.TypeName = "Мастер-класс"; break;
                case 4: productView.TypeName = "Подготовка к экзаменам"; break;
                case 5: productView.TypeName = "Практические занятия"; break;
            }

            return productView;
        }
Пример #5
0
 private ProductForAddEditViewModel ConvertFromProductToProductViewModelForAddEditView(Product product)
 {
     return new ProductForAddEditViewModel()
     {
         Id = product.Id,
         Name = product.Name,
         Description = product.Description,
         CreatedDate = product.CreatedDate,
         UpdatedDate = product.UpdatedDate,
         Active = product.Active,
         Type = product.Type,
         PartnerId = product.PartnerId,
         Teacher = product.Teacher,
         SeatsCount = product.SeatsCount ?? null,
         AssignedUserId = product.AssignedUserId ?? null,
         Location = product.Location,
         Image = (product.Image == null || product.Image.Length == 0) ? null : product.Image,
         ManagerName = (product.User != null) ? product.User.Login : "******",
         PartnerName = (product.Partner != null) ? product.Partner.Name : "Отсутствует"
     };
 }
Пример #6
0
 private ProductViewModel ConvertFromProductToProductViewModel(Product c)
 {
     return new ProductViewModel()
     {
         Id = c.Id,
         Name = c.Name,
         Description = c.Description,
         CreatedDate = c.CreatedDate,
         UpdatedDate = c.UpdatedDate,
         Active = c.Active,
         Type = c.Type,
         PartnerId = c.PartnerId,
         Teacher = c.Teacher,
         SeatsCount = c.SeatsCount ?? null,
         AssignedUserId = c.AssignedUserId ?? null,
         Location = c.Location,
         Image = (c.Image == null || c.Image.Length == 0) ? null : c.Image,
         ManagerName = (c.User != null) ? c.User.Login : "******",
         PartnerName = (c.Partner != null) ? c.Partner.Name : "Отсутствует",
     };
 }