Questions




Answers
2
Course to learn about matrix (two dimensional array) in C# with exercises and solution

Hi,please someone can give me link to learn about matrix (two dimensional array) in C# with exercises and solution. Thanks in advance.

...
Read More
Answers
1
ASP.NET Core - Dependency Injection

My controller:

    [Route("api/[controller]")]
    [ApiController]
    public class CategoriesController : ControllerBase
    {
        private readonly IUnitOfWork unitOfWork;

        public CategoriesController(IUnitOfWork unitOfWork)
        {
            this.unitOfWork = unitOfWork;
        }

        [HttpGet]
        [Route("TestCategories")]
        public ActionResult<IEnumerable<Category>> TestCategories()
        {
            return unitOfWork.Categories.FindAll().ToList();
        }
    }

My Startup:

        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext<ClassifiedAdsDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddScoped<IUnitOfWork, UnitOfWork>();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

I did break my app so i can understand how the codes work.

As you can see on my controller i used IUnitOfWork (Interface that comes from MyProject.Domain - class library) 

Scenario:

  1. if i use the UnitOfWork class, the only thing the i need to inject (to startup.cs) is the UnitOfWork class only.
  2. if i use the IUnitOfWork interface. i need to inject both (to startup.cs) IUnitOfWork interface and UnitOfWork class as well because it gives error see below.

...

Read More
Answers
2
PagedList in BootStrap pop-up Modal using Asp.Net CORE MVC

I am showing some data in modal pop-up using BootStrap .Basically I am using for each loop for displaying Data. So I would like to know, How To apply paging in these scenario using PagedList asp net core mvc or any other plugin in pop-up modal.

thank you

...
Read More
Answers
2
Search form's select dropdown does not work on Apple phones

I have a search form consisting of 5 html selects, on a site which is running Bootstrap 4.1. This does not work on Apple phones, because when the visitor touches the select, the dropdown of options does not appear. This works fine on computers and android devices. Does anyone have a work around?

...
Read More
Answers
2
How to find and extract only number from string in C#?

I have a string with numbers in it, for example here is the string "121 testing your City", now, I would like to extract only "121" from the string, how can I do that using C#?

...
Read More
Answers
4
Find common multiples between element of array in C#?

Hi, how can I get the common multiples of all element of array for example I have this array 2 4 3 . And I want to get the common multiples I do this code but not working. Can someone help me please. Thanks.

...
Read More
Answers
2
How to Switch ORM in Repository Pattern (C# .NET MVC)?

I have been searching on it how to switch ORM using repository pattern, and i was not able to find "examples/sample codes" of it so i can study with that. 

I believe my search keywords were wrong (ex. How to switch from EF to ADO.NET using Repo pattern and etc), thats why I can not find an article that talks about it.

Lets say we implement repository pattern with Entity Framework.

Is it repo pattern tightly coupled in Entity Framework? or

Do I need to create another Data Access Layer that talks for ADO.NET/or DAPPER/ Nhibernate?(for example)

Thanks in Advance.

...
Read More
Answers
2
How to implement validation for input type file using jQuery or javascript?

Hello, I have a HTML form inside which there is <input type="file" /> field, and now before posting form to the server side, I need to validate/check if file field is empty or not, I want user to upload atleast one image file in this field, so how I can implement validation message for <input type ="file" /> field in the form using jQuery or javascript code?

Sample HTML Form

...
Read More
Answers
3
What does Service Layer do? Repository Pattern / Unit Of Work

Do i need Service Layer? From my point of view/understanding.

Presentation Layer = UI

Business Logic Layer = Domain/Entities, Interface and (should DTO resides here)?

Data Access Layer = Implementation of Repository Pattern, CRUD.

Service Layer = ???

If the BLL has Domain/Entities? what layer does business validation belongs to? 

From what i know and searched. Entites and DTO is plain.

 

 

...
Read More
Answers
3
how to convert UTC time to Local using C#?

Hello, I would like to know how can I convert UTC datetime into local (user's pc) datetime in asp.net MVC razor page using C#?

I thought .ToLocalTime() should work, but I am not getting correct result.

...
Read More

Page 23 of 54