/// <summary>
        /// Получаем ВьюМодель на основе id ДатаМодели
        /// </summary>
        public static async Task <EssentialEditViewModel> GetViewModelByModel()
        {
            Essential essential = new Essential();

            using (CustomLightContext db = new CustomLightContext())
            {
                essential = await db.Essentials.FirstOrDefaultAsync();
            }
            return((EssentialEditViewModel)essential);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Получаем ВьюМодель на основе id ДатаМодели
        /// </summary>
        public static async Task <CategoryEditViewModel> GetViewModelByModelId(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            Category category = new Category();

            using (CustomLightContext db = new CustomLightContext())
            {
                category = await db.Categories.FindAsync(id);
            }
            return((CategoryEditViewModel)category);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Получаем ВьюМодель на основе id ДатаМодели
        /// </summary>
        public static async Task <PageEditViewModel> GetViewModelByModelId(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            Page page = new Page();

            using (CustomLightContext db = new CustomLightContext())
            {
                page = await db.Pages.FindAsync(id);
            }
            return((PageEditViewModel)page);
        }
Exemplo n.º 4
0
        public static async Task <SlideEditViewModel> GetViewModelByModelId(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            Slide slide = new Slide();

            using (CustomLightContext db = new CustomLightContext())
            {
                slide = await db.Slides.FindAsync(id);
            }

            return((SlideEditViewModel)slide);
        }
        /// <summary>
        /// Получаем ВьюМодель на основе id ДатаМодели
        /// </summary>
        public static async Task <ProductTypeEditViewModel> GetViewModelByModelId(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            var productType = new ProductType();

            using (var db = new CustomLightContext())
            {
                productType = await db.ProductTypes
                              .Include(pt => pt.SpecificationTitles)
                              .FirstOrDefaultAsync(pt => pt.Id == id);
            }
            return((ProductTypeEditViewModel)productType);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Получаем ВьюМодель на основе id ДатаМодели
        /// </summary>
        public static async Task <ProjectViewModel> GetViewModelByModelId(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            var project = new Project();

            using (var db = new CustomLightContext())
            {
                project = await db.Projects
                          .Include(p => p.CategoryProject)
                          .Include(p => p.ProjectImages)
                          .FirstOrDefaultAsync(p => p.Id == id);
            }
            return((ProjectViewModel)project);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Получаем ВьюМодель на основе id ДатаМодели
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public static async Task <ProductViewModel> GetViewModelByModelId(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            var product = new Product();

            using (var db = new CustomLightContext())
            {
                product = await db.Products
                          .Include(p => p.CategoryProduct)
                          .Include(p => p.ProductImages)
                          .Include(p => p.ProductType)
                          .ThenInclude(pt => pt.SpecificationTitles)
                          .Include(p => p.Specifications)
                          .ThenInclude(s => s.SpecificationValues)
                          .FirstOrDefaultAsync(p => p.Id == id);
            }
            return((ProductViewModel)product);
        }