Using the DropDownList with ASP.NET MVC Razor

by

السلام عليكم ,

في المقالة التالية سيتم شرح كيفية تركيب  

DropDownList with ASP.NET MVC  .

سيكون المثال عبارة عند جلب البيانات من   SQL Server  واظهارها في ASP.NET MVC Page   .

الجداول التالية في SQL Server 

Employees

Gender 

تعرف الحقول التاليه في C#  , كما هو مبين :

من اجل 

Employee Table  .

  Gender Table  .

 

تهيئة  EmployeeController  . من اجل العمل مع الداتا بير .

 

الشكل الذي سوف يظهر لدينا عند تشغيل المشروع  :

 

Code  GitHub

Image Uploader Using ASP.NET MVC 5

by

Image Uploader Using ASP.NET MVC 5

السلام عليكم , 

المقالة التالية سنشرح كيفية تركيب Image Uploader بستخدام التقنيات التالية 

 ASP.NET MVC and AJAX with SQL Server  .

 

الصوره التالية توضج , اضافة مجلد Upload الذي سيتم حفظ الصور داخله .

 

نقوم ايضا بانشاء SQLServer Database  , بالحقول التالية , التى بدورها ستخفظ مسار الصوره و حجمها على قاعد البيانات . 

 

 

 

 

Code GitHub

 

 

Load Me ASP.NET MVC 5 AJAX

by

Load Me ASP.NET MVC 5 AJAX  

 

السلام عليكم ,

في المثال التالي سوف نحاول استخدام AJAX  مع ASP.NET MVC  , واظهار موشر مشغولية المعالج , في اثناء تنفيذ اي عمليه.

 

 public class EmployeeController : Controller    {        private readonly IEmployee _Employee;        public EmployeeController(IEmployee employee)        {            _Employee = employee;        }        // GET: Employee        public ActionResult Index()        {            return View();        }        [HttpGet]        public ActionResult GetEmployees()        {           return PartialView("_GetEmployees", _Employee.GetEmployee);        }    }

 

Index Pege :

 

@{    ViewBag.Title = "Index";}<link href="~/Content/loadme.css" rel="stylesheet" />@{    var options = new AjaxOptions()    {        UpdateTargetId = "DivContent",        InsertionMode = InsertionMode.Replace,        HttpMethod = "Get",        OnBegin = "onLoadBegin",        OnSuccess = "onLoadSuccess"    };}<br/>@Ajax.ActionLink("Employees", "GetEmployees", "Employee", options,new { @class = "btn btn-primary" })<hr/><div id="DivContent">    Your PartialView Will be here. </div><div id="divLoading" style="display:none">    <div class="loadmeRect">        <div class="loadmeRectChild loadmeRect1"></div>        <div class="loadmeRectChild loadmeRect2"></div>        <div class="loadmeRectChild loadmeRect3"></div>        <div class="loadmeRectChild loadmeRect4"></div>        <div class="loadmeRectChild loadmeRect5"></div>    </div>    <div class="loadme-mask"></div></div>

 

partial View

 

@model IEnumerable<TestLoadMeAjax.Models.Employee><p>    @Html.ActionLink("Create New", "Create")</p><table class="table">    <tr>        <th>            @Html.DisplayNameFor(model => model.Name)        </th>        <th>            @Html.DisplayNameFor(model => model.Gender)        </th>        <th>            @Html.DisplayNameFor(model => model.Salary)        </th>        <th></th>    </tr>@foreach (var item in Model) {    <tr>        <td>            @Html.DisplayFor(modelItem => item.Name)        </td>        <td>            @Html.DisplayFor(modelItem => item.Gender)        </td>        <td>            @Html.DisplayFor(modelItem => item.Salary)        </td>        <td>            @Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "btn btn-warning" })|            @Html.ActionLink("Details", "Details", new { id=item.Id }, new { @class = "btn btn-warning" }) |            @Html.ActionLink("Delete", "Delete", new { id=item.Id }, new { @class = "btn btn-warning" })        </td>    </tr>}</table>

Code GitHub

 

 

Onion Architecture in ASP.Net MVC ????? ??????

by

Database initialize class

???? ?? ???? ?????? ????? ???????? ?? ?????? ?????? .

??? ?? ????? ?????? :

 

Repository class implementation

 

?????? ??????? ????? ???? ?????? ??????? ?? ???? ?????????? repository class , ????? ????? ??????? ??? ????? ???????? ??????? LINQ ??? Entity  .

?????? BloodDonorRepository  , ???? ?? ???? ??? ???? ?????? ??  IBloodDonorRepository interface

 

?????? ??????? ?? ?????????? , ??? ?????? LINQ to Entity  ?? ??? ???????? ?? ????? ???????? , ??? ???? ?????? ?????

a blood donor

 

  1. Create object of context class
  2. Use context.entiy.Add(entity)
  3. Use context.SaveChnages()

 

 

???? ?????? ????? ??? ????? ???? ?????????? ????????? ?? ??????? , ????? ??? ??? ????? ??? Build  ??????? , ??????? ?? ????? ????? .

 

Web Project 


??? ???? ?????? ????? MVC  , ???? ????? ??????? ?? ???????? ??????? Core and Interface  , ?? ?????? ??????? ??????? ??? ?????? .

  1. infrastructure project
  2. core project
  3. Entity Framework package

 

??? ????? ?? ??????? , ?? ???? Build ????? ?? ?? ?? ?? ???? .

?? ??????  New Controller  ?? Entity Framework  .??? ?????? ??????  BloodDonorsController  .

????? ????? ?????? ???????? ??????? :

  1. BloodDonor class from the core project as the Model class
  2. BloodDonorContext class as the data context class from the Infrastructure project

Onion Architecture in ASP.Net MVC ????? ??????

by

Core project

 

 

?????? ???????? , ?? ?????? ?????? ?? ???? ??????? , ?? ??????? ???? ??? ??? ?????? Web layer , Infrastructure layer , ????? ??? ??? ?????? .

 

 

?? ????? ?? ?????? ???????? core  ?? ???? ??? ?? ???? ???? .

?????? ?? ????? Core layer  ??? ?????? :

???? ???????? (Domain Entities)

?????? ?????????? ??????? (Repositories interfaces)

??? ?? ?? ???? ?? ?????? ??? ????? ?????? , ??? :

Reference of the ORM like LINQ to SQL or EF

  1. ORM like LINQ to SQL or EF
  2. ADO.NET libraries
  3. Entity Framework .

Create Entity

?????? , Entity  ????? ?????? BloodDonor entity class. .

 

?? ???? ????? ??? ?????? , ????? ????? , ??? ??? ???????? ??????? ?? ??? , ?? ???? ?????? ???? ?????? , ?????? ?? ???????  .

????? ???????? ??????? , ???? ??? ?? ????? ???? :

  1. System.ComponentModel.DataAnnotations
  2. Entity Framework fluent API.

??? ????????? ???????? , ???? ?????? . ?? ??? ???? ?????? ???????? ???? ?? ????? ?????? ??? EntityFramework , ??? ???? ??????? DataAnnotations  .

???????? DataAnnotations  ?? ?????? ?????? ?????? , ??? ????? .

System.ComponentModel.DataAnnotations

 

??? ????? BloodDonor entity class ?? DataAnnotations  .

?????? ??????? ????? ?????? ???????? ??????? repository interface

Repository interface

??? ???? ????? ?????????? repository  ,   ??? ?????????? ???? ?? ??????? ???? ?????? ?????? ???????? ??? ??????? ??? ?? ???? ???? .

?? ?????? ?????????? repository interface , ??? ??? ????? ?? ?????? ????? ???????? ???? ??????? .

 

??? ???????? ?? ????? ?? ??????? ?????????? ?? ?????? ,?????? ??????? ????? ???? ??????? infrastructure project .

Infrastructure project

 

?? ????? ?????? ??????? ,??? ???? ????? ???????? ???????? ???? ???????.

  1. Database operation
  2. Accessing outside service
  3. Accessing File systems

 

?????? ?? ???? ???????? ??????? ???? ?? ????? ?????? ???????. ??? ??????  Entity Framework ?????? ?????? ????? ????????. ??? ???? ??  Entity Framework code first .

 ???? ??? ????? ?????? ??????? ???????:

  1. Create the data context class
  2. Implement the repository class
  3. Create the database initializer class

??? ????? data context class , ??? ????? ???? Entity Framework , ?? Nuget Package Manager .

DataContext class
 

????? ?????? Data context class  .

 

Connection string

< connectionStrings >< add name = "BloodDonorContextConnectionString" connectionString = "Data Source= LocalDb)\v11.0;Initial Catalog=BloodDonors;Integrated Security=True;MultipleActiveResultSets=true" providerName = "System.Data.SqlClient" / >< /connectionStrings>

 

???? ......

 

Source:c-sharpcorner,debugmode