<file_sep>﻿using MS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Text;

namespace MS.Domain.CommonModels
{
    public class Page<T>
    {
        public IEnumerable<T> Data { get; set; }
        public int PageCount { get; set; }

    }
}
<file_sep>﻿using AutoMapper;
using MS.Domain.Entities;
using MS.Infrastructure.DAL.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MS.Infrastructure.ObjectMapping
{
    public class MSProfile : Profile
    {
        public MSProfile()
        {
            CreateMap<MobileVideoModel, MobileVideo>();
            CreateMap<MobilePhotoModel, MobilePhoto>();
            CreateMap<MobileModel, Mobile>().ForMember(
                d => d.Video,
                op => op.MapFrom(s => s.Videos.FirstOrDefault())
                );
        }
    }
}
<file_sep>﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace MS.Infrastructure.DAL.Models
{
    public class MobileVideoModel
    {
        [Key]
        public int ID { get; set; }
        public string Link { get; set; }
        public int MobileID { get; set; }
        public MobileModel Mobile { get; set; }

    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace MS.Infrastructure.DAL.Models
{
    public class MobileModel
    {
        [Key]
        public int ID { get; set; }
        public string Name { get; set; }
        public string Manufacturer { get; set; }
        public string Dimensions { get; set; }
        public string Weight { get; set; }
        public string ScreenSize { get; set; }
        public string Resolution { get; set; }
        public string Processor { get; set; }
        public string Memory { get; set; }
        public string OS { get; set; }
        public decimal Price { get; set; }
        public virtual ICollection<MobileVideoModel> Videos { get; set; }
        public virtual ICollection<MobilePhotoModel> Photos { get; set; }

    }
}
<file_sep>﻿using MediatR;
using MS.Domain.Abstractions.Repositories;
using MS.Domain.CommonModels;
using MS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MS.Application.UseCases.Mobiles.Queries.GetMobilesList
{
    public class GetMobilesListHandler : IRequestHandler<GetMobilesListRequest, Page<Mobile>>
    {
        private IMobilesRepository _mobilesRepository;
        public GetMobilesListHandler(IMobilesRepository mobilesRepository)
        {
            _mobilesRepository = mobilesRepository;
        }

        public async Task<Page<Mobile>> Handle(GetMobilesListRequest request, CancellationToken cancellationToken)
        {
            var filter = new MobilesFilter() {
                Manufacturer = request.Manufacturer,
                Name = request.Name,
                PriceFrom = request.PriceFrom,
                PriceTo = request.PriceTo,
                Page = request.Page
            };
            return await _mobilesRepository.GetMobilesList(filter);
        }
    }
}
<file_sep>﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace MS.Infrastructure.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Mobiles",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(nullable: true),
                    Manufacturer = table.Column<string>(nullable: true),
                    Dimensions = table.Column<string>(nullable: true),
                    Weight = table.Column<string>(nullable: true),
                    ScreenSize = table.Column<string>(nullable: true),
                    Resolution = table.Column<string>(nullable: true),
                    Processor = table.Column<string>(nullable: true),
                    Memory = table.Column<string>(nullable: true),
                    OS = table.Column<string>(nullable: true),
                    Price = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Mobiles", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Photos",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Link = table.Column<string>(nullable: true),
                    MobileID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Photos", x => x.ID);
                    table.ForeignKey(
                        name: "FK_Photos_Mobiles_MobileID",
                        column: x => x.MobileID,
                        principalTable: "Mobiles",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Videos",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Link = table.Column<string>(nullable: true),
                    MobileID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Videos", x => x.ID);
                    table.ForeignKey(
                        name: "FK_Videos_Mobiles_MobileID",
                        column: x => x.MobileID,
                        principalTable: "Mobiles",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Photos_MobileID",
                table: "Photos",
                column: "MobileID");

            migrationBuilder.CreateIndex(
                name: "IX_Videos_MobileID",
                table: "Videos",
                column: "MobileID");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Photos");

            migrationBuilder.DropTable(
                name: "Videos");

            migrationBuilder.DropTable(
                name: "Mobiles");
        }
    }
}
<file_sep>﻿using MS.Domain.CommonModels;
using MS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MS.Domain.Abstractions.Repositories
{
    public interface IMobilesRepository
    {
        Task<Page<Mobile>> GetMobilesList(MobilesFilter filter);
        Task<Mobile> GetDetails(int id);
    }
}
<file_sep>﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace MS.Infrastructure.Migrations
{
    public partial class SeedData : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.InsertData(
                table: "Mobiles",
                columns: new[] { "ID", "Dimensions", "Manufacturer", "Memory", "Name", "OS", "Price", "Processor", "Resolution", "ScreenSize", "Weight" },
                values: new object[] { 1, "144mm X 71.4mm X 8.1mm", "Apple", "4GB", "Iphone 11 pro", "IOS", 3500m, "hexa-core Apple A13", "2436 x 1125", "5.8 inch", "188g" });

            migrationBuilder.InsertData(
                table: "Mobiles",
                columns: new[] { "ID", "Dimensions", "Manufacturer", "Memory", "Name", "OS", "Price", "Processor", "Resolution", "ScreenSize", "Weight" },
                values: new object[] { 2, "144mm X 71.4mm X 8.1mm", "Apple", "3GB", "Iphone 7", "IOS", 1800m, "hexa-core Apple A9", "2436 x 1125", "4.7 inch", "159g" });

            migrationBuilder.InsertData(
                table: "Mobiles",
                columns: new[] { "ID", "Dimensions", "Manufacturer", "Memory", "Name", "OS", "Price", "Processor", "Resolution", "ScreenSize", "Weight" },
                values: new object[] { 3, "144mm X 71.4mm X 8.1mm", "Samsung", "6GB", "Galaxy s20", "Android", 3500m, "Snapdragon 855", "2436 x 1125", "6.1 inch", "188g" });

            migrationBuilder.InsertData(
                table: "Videos",
                columns: new[] { "ID", "Link", "MobileID" },
                values: new object[] { 1, "http://google.com", 1 });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 2);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 3);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 1);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 1);
        }
    }
}
<file_sep>﻿using Microsoft.EntityFrameworkCore;
using MS.Domain.Entities;
using MS.Infrastructure.DAL.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace MS.Infrastructure.DAL.Context
{
    public class MSContext : DbContext
    {
        public MSContext(DbContextOptions options) : base(options)
        {
        }

        public DbSet<MobileModel> Mobiles { get; set; }
        public DbSet<MobileVideoModel> Videos { get; set; }
        public DbSet<MobilePhotoModel> Photos { get; set; }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<MobileModel>().HasData(
                new MobileModel
                {
                    ID = 1,
                    Name = "Iphone 11 pro",
                    Manufacturer = "Apple",
                    OS = "IOS",
                    Price = 3500,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "hexa-core Apple A13",
                    Resolution = "2436 x 1125",
                    ScreenSize = "5.8 inch",
                    Weight = "188g",
                    Memory = "4GB"
                },
                new MobileModel
                {
                    ID = 2,
                    Name = "Iphone 7",
                    Manufacturer = "Apple",
                    OS = "IOS",
                    Price = 1800,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "hexa-core Apple A9",
                    Resolution = "2436 x 1125",
                    ScreenSize = "4.7 inch",
                    Weight = "159g",
                    Memory = "3GB"
                },
                new MobileModel
                {
                    ID = 3,
                    Name = "Galaxy s20",
                    Manufacturer = "Samsung",
                    OS = "Android",
                    Price = 3500,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "Snapdragon 855",
                    Resolution = "2436 x 1125",
                    ScreenSize = "6.1 inch",
                    Weight = "188g",
                    Memory = "6GB"
                },
                new MobileModel
                {
                    ID = 4,
                    Name = "Galaxy s4",
                    Manufacturer = "Samsung",
                    OS = "Android",
                    Price = 1234,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "Snapdragon 650",
                    Resolution = "1200 x 850",
                    ScreenSize = "5.0 inch",
                    Weight = "145g",
                    Memory = "3GB"
                },
                new MobileModel
                {
                    ID = 5,
                    Name = "Honor 4c",
                    Manufacturer = "Huawei",
                    OS = "Android",
                    Price = 500,
                    Dimensions = "130mm X 65.4mm X 7.3mm",
                    Processor = "Snapdragon 550",
                    Resolution = "1800 x 850",
                    ScreenSize = "4.7 inch",
                    Weight = "130g",
                    Memory = "2GB"
                },
                new MobileModel
                {
                    ID = 6,
                    Name = "P30",
                    Manufacturer = "Huawei",
                    OS = "Android",
                    Price = 900,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "Snapdragon 855",
                    Resolution = "2436 x 1125",
                    ScreenSize = "5.7 inch",
                    Weight = "175g",
                    Memory = "4GB"
                },
                new MobileModel
                {
                    ID = 7,
                    Name = "Iphone SE",
                    Manufacturer = "Apple",
                    OS = "IOS",
                    Price = 1500,
                    Dimensions = "130mm X 65.5mm X 8.1mm",
                    Processor = "hexa-core Apple A12",
                    Resolution = "1900 x 900",
                    ScreenSize = "4.7 inch",
                    Weight = "160g",
                    Memory = "3GB"
                },
                new MobileModel
                {
                    ID = 8,
                    Name = "Galaxy A80",
                    Manufacturer = "Samsung",
                    OS = "Android",
                    Price = 1700,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "Snapdragon 855",
                    Resolution = "2436 x 1125",
                    ScreenSize = "6.0 inch",
                    Weight = "188g",
                    Memory = "4GB"
                },
                new MobileModel
                {
                    ID = 9,
                    Name = "<NAME> 9",
                    Manufacturer = "Xiaomi",
                    OS = "Android",
                    Price = 1499,
                    Dimensions = "162.3mm X 77.2mm X 8.9mm",
                    Processor = "MediaTek Helio G85",
                    Resolution = "1080 x 2340",
                    ScreenSize = "6.53 inch",
                    Weight = "199g",
                    Memory = "4GB"
                },
                new MobileModel
                {
                    ID = 10,
                    Name = "<NAME>",
                    Manufacturer = "Nokia",
                    OS = "Windows Phone",
                    Price = 120,
                    Dimensions = "144mm X 71.4mm X 8.1mm",
                    Processor = "Snapdragon S4 Plus",
                    Resolution = "1280 x 768",
                    ScreenSize = "4.5 inch",
                    Weight = "158g",
                    Memory = "32GB 2GB RAM"
                });
            modelBuilder.Entity<MobileVideoModel>().HasData(
                new MobileVideoModel
                {
                    ID = 1,
                    MobileID = 1,
                    Link = "https://www.youtube.com/watch?v=OoY7zp8GkLI&ab_channel=MarquesBrownlee"
                },
                new MobileVideoModel
                {
                    ID = 2,
                    MobileID = 2,
                    Link = "https://www.youtube.com/watch?v=nxf41fMX_Y4&ab_channel=MarquesBrownlee"
                },
                new MobileVideoModel
                {
                    ID = 3,
                    MobileID = 3,
                    Link = "https://www.youtube.com/watch?v=ZdC9soHxVC8&ab_channel=MarquesBrownlee"
                },
                new MobileVideoModel
                {
                    ID = 4,
                    MobileID = 4,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                },
                new MobileVideoModel
                {
                    ID = 5,
                    MobileID = 5,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                },
                new MobileVideoModel
                {
                    ID = 6,
                    MobileID = 6,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                },
                new MobileVideoModel
                {
                    ID = 7,
                    MobileID = 7,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                },
                new MobileVideoModel
                {
                    ID = 8,
                    MobileID = 8,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                },
                new MobileVideoModel
                {
                    ID = 9,
                    MobileID = 9,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                },
                new MobileVideoModel
                {
                    ID = 10,
                    MobileID = 10,
                    Link = "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy"
                });

            modelBuilder.Entity<MobilePhotoModel>().HasData(
                new MobilePhotoModel
                {
                    ID = 1,
                    MobileID = 1,
                    Link = "https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-11-pro-max-4.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 11,
                    MobileID = 1,
                    Link = "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-11-pro-max-.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 2,
                    MobileID = 2,
                    Link = "https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-7-3.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 3,
                    MobileID = 3,
                    Link = "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-s20-ultra-.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 4,
                    MobileID = 4,
                    Link = "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-s-4-i9500-black-mist.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 5,
                    MobileID = 5,
                    Link = "https://fdn2.gsmarena.com/vv/pics/huawei/huawei-honor-4c-1.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 6,
                    MobileID = 6,
                    Link = "https://fdn2.gsmarena.com/vv/pics/huawei/huawei-p30-1.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 7,
                    MobileID = 7,
                    Link = "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-se-2020.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 8,
                    MobileID = 8,
                    Link = "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-a80-.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 9,
                    MobileID = 9,
                    Link = "https://fdn2.gsmarena.com/vv/pics/xiaomi/xiaomi-redmi-note-9-4.jpg"
                },
                new MobilePhotoModel
                {
                    ID = 10,
                    MobileID = 10,
                    Link = "https://fdn2.gsmarena.com/vv/pics/nokia/nokia-lumia-1020.jpg"
                });
        }

    }
}
<file_sep>﻿using MediatR;
using MS.Domain.Abstractions.Repositories;
using MS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MS.Application.UseCases.Mobiles.Queries.GetDetails
{
    class GetDetailsHandler : IRequestHandler<GetDetailsRequest, Mobile>
    {
        private IMobilesRepository _mobilesRepository;
        public GetDetailsHandler(IMobilesRepository mobilesRepository)
        {
            _mobilesRepository = mobilesRepository;
        }

        public async Task<Mobile> Handle(GetDetailsRequest request, CancellationToken cancellationToken)
        {
            return await _mobilesRepository.GetDetails(request.ID);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using MS.Application.UseCases.Mobiles.Queries.GetDetails;
using MS.Application.UseCases.Mobiles.Queries.GetMobilesList;
using MS.Domain.Entities;
using MS.Web.Models;

namespace MS.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        private IMediator _mediator;

        public HomeController(ILogger<HomeController> logger, IMediator mediator)
        {
            _mediator = mediator;
            _logger = logger;
        }

        public async Task<IActionResult> Index(int? id, [FromQuery] GetMobilesListRequest request)
        {
            request.Page = id == null ? 1 : id.Value;
            var mobiles = await _mediator.Send(request);
            ViewBag.CurrentPage = request.Page;
            return View(mobiles);
        }

        public async Task<IActionResult> Details(int id)
        {
            var request = new GetDetailsRequest();
            request.ID = id;
            var mobile = await _mediator.Send(request);
            return View(mobile);
        }


        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
<file_sep>﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace MS.Infrastructure.Migrations
{
    public partial class SeedData2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.InsertData(
                table: "Mobiles",
                columns: new[] { "ID", "Dimensions", "Manufacturer", "Memory", "Name", "OS", "Price", "Processor", "Resolution", "ScreenSize", "Weight" },
                values: new object[,]
                {
                    { 4, "144mm X 71.4mm X 8.1mm", "Samsung", "3GB", "Galaxy s4", "Android", 1234m, "Snapdragon 650", "1200 x 850", "5.0 inch", "145g" },
                    { 5, "130mm X 65.4mm X 7.3mm", "Huawei", "2GB", "Honor 4c", "Android", 500m, "Snapdragon 550", "1800 x 850", "4.7 inch", "130g" },
                    { 6, "144mm X 71.4mm X 8.1mm", "Huawei", "4GB", "P30", "Android", 900m, "Snapdragon 855", "2436 x 1125", "5.7 inch", "175g" },
                    { 7, "130mm X 65.5mm X 8.1mm", "Apple", "3GB", "Iphone SE", "IOS", 1500m, "hexa-core Apple A12", "1900 x 900", "4.7 inch", "160g" },
                    { 8, "144mm X 71.4mm X 8.1mm", "Samsung", "4GB", "Galaxy A80", "Android", 1700m, "Snapdragon 855", "2436 x 1125", "6.0 inch", "188g" },
                    { 9, "162.3mm X 77.2mm X 8.9mm", "Xiaomi", "4GB", "Redmi note 9", "Android", 1499m, "MediaTek Helio G85", "1080 x 2340", "6.53 inch", "199g" },
                    { 10, "144mm X 71.4mm X 8.1mm", "Nokia", "32GB 2GB RAM", "Lumia 1020", "Windows Phone", 120m, "Snapdragon S4 Plus", "1280 x 768", "4.5 inch", "158g" }
                });

            migrationBuilder.InsertData(
                table: "Photos",
                columns: new[] { "ID", "Link", "MobileID" },
                values: new object[,]
                {
                    { 1, "https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-11-pro-max-4.jpg", 1 },
                    { 11, "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-11-pro-max-.jpg", 1 },
                    { 2, "https://fdn2.gsmarena.com/vv/pics/apple/apple-iphone-7-3.jpg", 2 },
                    { 3, "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-s20-ultra-.jpg", 3 }
                });

            migrationBuilder.UpdateData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 1,
                column: "Link",
                value: "https://www.youtube.com/watch?v=OoY7zp8GkLI&ab_channel=MarquesBrownlee");

            migrationBuilder.InsertData(
                table: "Videos",
                columns: new[] { "ID", "Link", "MobileID" },
                values: new object[,]
                {
                    { 2, "https://www.youtube.com/watch?v=nxf41fMX_Y4&ab_channel=MarquesBrownlee", 2 },
                    { 3, "https://www.youtube.com/watch?v=ZdC9soHxVC8&ab_channel=MarquesBrownlee", 3 }
                });

            migrationBuilder.InsertData(
                table: "Photos",
                columns: new[] { "ID", "Link", "MobileID" },
                values: new object[,]
                {
                    { 4, "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-s-4-i9500-black-mist.jpg", 4 },
                    { 5, "https://fdn2.gsmarena.com/vv/pics/huawei/huawei-honor-4c-1.jpg", 5 },
                    { 6, "https://fdn2.gsmarena.com/vv/pics/huawei/huawei-p30-1.jpg", 6 },
                    { 7, "https://fdn2.gsmarena.com/vv/bigpic/apple-iphone-se-2020.jpg", 7 },
                    { 8, "https://fdn2.gsmarena.com/vv/bigpic/samsung-galaxy-a80-.jpg", 8 },
                    { 9, "https://fdn2.gsmarena.com/vv/pics/xiaomi/xiaomi-redmi-note-9-4.jpg", 9 },
                    { 10, "https://fdn2.gsmarena.com/vv/pics/nokia/nokia-lumia-1020.jpg", 10 }
                });

            migrationBuilder.InsertData(
                table: "Videos",
                columns: new[] { "ID", "Link", "MobileID" },
                values: new object[,]
                {
                    { 4, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 4 },
                    { 5, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 5 },
                    { 6, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 6 },
                    { 7, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 7 },
                    { 8, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 8 },
                    { 9, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 9 },
                    { 10, "https://www.youtube.com/watch?v=zrc2UAMnr94&ab_channel=UnboxTherapy", 10 }
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 1);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 2);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 3);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 4);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 5);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 6);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 7);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 8);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 9);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 10);

            migrationBuilder.DeleteData(
                table: "Photos",
                keyColumn: "ID",
                keyValue: 11);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 2);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 3);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 4);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 5);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 6);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 7);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 8);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 9);

            migrationBuilder.DeleteData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 10);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 4);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 5);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 6);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 7);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 8);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 9);

            migrationBuilder.DeleteData(
                table: "Mobiles",
                keyColumn: "ID",
                keyValue: 10);

            migrationBuilder.UpdateData(
                table: "Videos",
                keyColumn: "ID",
                keyValue: 1,
                column: "Link",
                value: "http://google.com");
        }
    }
}
<file_sep>﻿using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MS.Domain.Abstractions.Repositories;
using MS.Infrastructure.DAL.Context;
using MS.Infrastructure.DAL.Repositories;
using System;
using System.Collections.Generic;
using System.Text;

namespace MS.Infrastructure
{
    public static class DependencyInjection
    {
        public static IServiceCollection AddInfrastucture(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddDbContext<MSContext>(opts => opts.UseSqlServer(configuration["ConnectionString:MobilesStore"]));

            services.AddScoped<IMobilesRepository, MobileRepository>();

            services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

            return services;
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MS.Domain.Abstractions.Repositories
{
    public class MobilesFilter
    {
        public string Name { get; set; }
        public string Manufacturer { get; set; }
        public int? PriceFrom { get; set; }
        public int? PriceTo { get; set; }
        public int Page { get; set; }

    }
}
<file_sep>﻿namespace MS.Domain.Entities
{
    public class MobileVideo
    {
        public int ID { get; set; }
        public string Link { get; set; }
    }
}<file_sep>﻿using AutoMapper;
using Microsoft.EntityFrameworkCore;
using MS.Domain.Abstractions.Repositories;
using MS.Domain.CommonModels;
using MS.Domain.Entities;
using MS.Infrastructure.DAL.Context;
using MS.Infrastructure.DAL.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MS.Infrastructure.DAL.Repositories
{
    class MobileRepository : IMobilesRepository
    {
        private const int ItemsPerPage = 6;
        private readonly MSContext _context;
        private readonly IMapper _mapper;

        public MobileRepository(MSContext context, IMapper mapper)
        {
            _context = context;
            _mapper = mapper;
        }

        public async Task<Mobile> GetDetails(int id)
        {
            var p = await _context
                .Mobiles
                .Include(a => a.Videos)
                .Include(a => a.Photos)
                .FirstOrDefaultAsync(i => i.ID == id);

            if (p == null) return null;

            return _mapper.Map<Mobile>(p);
        }

        public async Task<Page<Mobile>> GetMobilesList(MobilesFilter filter)
        {
            var result = _context.Mobiles
                .Include(a => a.Videos)
                .Include(a => a.Photos)
                .AsQueryable();

            if (!string.IsNullOrEmpty(filter.Name))
                result = result.Where(i => EF.Functions.Like(i.Name, $"%{filter.Name}%"));
            if (!string.IsNullOrEmpty(filter.Manufacturer))
                result = result.Where(i => EF.Functions.Like(i.Manufacturer, $"%{filter.Manufacturer}%"));
            if (filter.PriceFrom != null)
                result = result.Where(i => i.Price >= filter.PriceFrom);
            if (filter.PriceTo != null)
                result = result.Where(i => i.Price <= filter.PriceTo);

            var pageCount = result.Count();
            result = result.Skip((filter.Page-1) * ItemsPerPage);
            result = result.Take(ItemsPerPage);
            

            return new Page<Mobile> { Data = _mapper.Map<IEnumerable<Mobile>>(await result.ToListAsync()), PageCount = pageCount };
        }
    }
}
<file_sep>"# MobileStore" 
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MS.Domain.Entities
{
    public class Mobile
    {
        public Mobile()
        {
            Photos = new List<MobilePhoto>();
        }
        public int ID { get; set; }
        public string Name { get; set; }
        public string Manufacturer { get; set; }
        public string Dimensions { get; set; }
        public string Weight { get; set; }
        public string ScreenSize { get; set; }
        public string Resolution { get; set; }
        public string Processor { get; set; }
        public string Memory { get; set; }
        public string OS { get; set; }
        public decimal Price { get; set; }
        public MobileVideo Video { get; set; }
        public List<MobilePhoto> Photos { get; set; }


    }
}
<file_sep>﻿using MediatR;
using MS.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Text;

namespace MS.Application.UseCases.Mobiles.Queries.GetDetails
{
    public class GetDetailsRequest : IRequest<Mobile>
    {
        public int ID { get; set; }
    }
}
