Advertisement

Advertisement

Asp.net mvc framework code 1st approach using n-tier architecture(Repository Pattern)

 

Asp.net mvc code 1st approach using n-tier architecture(Repository Pattern)

WebApp1.DAL

Data-> ApplicationDbContext.cs

Infrastrure->

    IRepository->IRepository.cs, IRoomRepository.cs, IUnitOfWork

    Repository->Repository.cs, RoomRepository.cs, UnitOfWork

Migrations file(automatic generate hota h after pmc me enable migrate karne pe)

WebApp1.Hotel

 Controller

HotelVMController.cs

ViewModel

HotelVM.cs

WebApp1.Model

HotelBooking.cs

HotelMaster.cs

HotelRoom.cs

------------------------------------------------------------------------------------------------------------

ApplicationDbContext.cs

using System;

using System.Collections.Generic;

using System.Data.Entity;

using System.Linq;

using System.Web;

using WebAppl1.Model.Models;

 

namespace WebAppl1.DAL.Data

{

    public class ApplicationDbContext : DbContext

    {

        public ApplicationDbContext()

            : base("name=MySqlConnection")

        {

        }

        public DbSet<HotelRoom> HotelRooms { get; set; }

        public DbSet<HotelMaster> HotelMasters { get; set; }

        public DbSet<HotelBooking> HotelBookings { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)

        {

 

        }

    }

}

Web.Config

<connectionStrings>

    <add name="MySqlConnection" connectionString="Data Source=DESKTOP-JJDFFJA\SQLEXPRESS;Integrated Security=true;Initial Catalog=AppHotelDB" providerName="System.Data.SqlClient" />

  </connectionStrings>

 

PMC (Package Manager Console)

Enable-Migrations

Add-Migration AddDb

Update-database

 

-------------------------------------------------------------------------------------------------------------

IRepository.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Linq.Expressions;

using System.Text;

using System.Threading.Tasks;

 

namespace WebAppl1.DAL.Infrastructure.IRepository

{

    public interface IRepository<T> where T: class

    {

        IEnumerable<T> GetAll();

        T GetT(Expression<Func<T, bool>> predicate);

        void Add(T entity);

        void Delete(T entity);

        void DeleteRange(IEnumerable<T> entity);

 

    }

}

++++++++++++++++++++++++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using WebAppl1.Model.Models;

 

namespace WebAppl1.DAL.Infrastructure.IRepository

{

    public interface IRoomRepository : IRepository<HotelRoom>

    {

        void Update(HotelRoom hotelRoom);

    }

}

++++++++++++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace WebAppl1.DAL.Infrastructure.IRepository

{

    public interface IUnitOfWork

    {

        IRoomRepository HotelRoom { get; }

        IMasterRepository HotelMaster { get; }

        //IBookingRepository HotelBooking { get; }

        void Save();

        void Dispose();

    }

}

-------------------------------------------------------------------------------------------------

using System;

using System.Collections.Generic;

using System.Data.Entity;

using System.Linq;

using System.Linq.Expressions;

using System.Text;

using System.Threading.Tasks;

using WebAppl1.DAL.Data;

using WebAppl1.DAL.Infrastructure.IRepository;

 

namespace WebAppl1.DAL.Infrastructure.Repository

{

    public class Repository<T> : IRepository<T> where T : class

    {

        private readonly ApplicationDbContext _context;

 

        private readonly DbSet<T> _dbSet;

 

        public Repository(ApplicationDbContext context)

        {

            _context = context;

            _dbSet = _context.Set<T>();

        }

        public Repository()

        {

            //_context = context;

            //_dbSet = _context.Set<T>();

        }

        public void Add(T entity)

        {

            _dbSet.Add(entity);

        }

 

        public void Delete(T entity)

        {

            _dbSet.Remove(entity);

        }

 

        public void DeleteRange(IEnumerable<T> entity)

        {

            _dbSet.RemoveRange(entity);

        }

 

        public IEnumerable<T> GetAll()

        {

            return _dbSet.ToList();

        }

 

        public T GetT(Expression<Func<T, bool>> predicate)

        {

            return _dbSet.Where(predicate).FirstOrDefault();

        }

    }

}

=+++++++++++++++++++++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using WebAppl1.DAL.Data;

using WebAppl1.DAL.Infrastructure.IRepository;

using WebAppl1.Model.Models;

 

namespace WebAppl1.DAL.Infrastructure.Repository

{

    public class RoomRepository : Repository<HotelRoom>, IRoomRepository

    {

        private ApplicationDbContext _context;

 

        public RoomRepository(ApplicationDbContext context) : base(context)

        {

            _context = context;

        }

        public void Update(HotelRoom hotelRoom)

        {

            _context.HotelRooms.Add(hotelRoom);

        }

    }

}

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using WebAppl1.DAL.Data;

using WebAppl1.DAL.Infrastructure.IRepository;

 

namespace WebAppl1.DAL.Infrastructure.Repository

{

    public class UnitOfWork : IUnitOfWork

    {

        private ApplicationDbContext _context;

        public IRoomRepository HotelRoom { get; private set; }

       // public IBookingRepository HotelBooking { get; private set; }

        public IMasterRepository HotelMaster { get; private set; }

 

        public UnitOfWork(ApplicationDbContext context)

        {

            _context = context;

            HotelRoom = new RoomRepository(context);

            HotelMaster = new MasterRepository(context);

           // HotelBooking = new BookingRepository(context);

        }

 

 

        #region old code ===========================================

        public void Save()

        {

            _context.SaveChanges();

        }

 

        public void Dispose()

        {

            throw new NotImplementedException();

        }

        #endregion

    }

}

=========================================================================================

using System;

using System.Collections.Generic;

using System.Data.Entity;

using System.Linq;

using System.Net;

using System.Web;

using System.Web.Mvc;

using WebAppl1.DAL.Data;

using WebAppl1.Hotel.ViewModel;

using WebAppl1.Model.Models;

 

namespace WebAppl1.Hotel.Controllers

{

    public class HotelVMController : Controller

    {

        private ApplicationDbContext db = new ApplicationDbContext();

        // GET: HotelVM

       

        public ActionResult GetHotel()

        {

            return View(db.HotelMasters.ToList());

        }

        public ActionResult Index()

        {

           

                var CitiesfromDb = new SelectList(db.HotelMasters.ToList(), "ID", "City");

                var NoOfRoomfromDb = new SelectList(db.HotelBookings.ToList(), "ID", "NumberOfRooms");

                var TypeofRoomfromDb = new SelectList(db.HotelBookings.ToList(), "ID", "RoomType");

                ViewData["Cities"] = CitiesfromDb;

                ViewData["NoOfRoom"] = NoOfRoomfromDb;

                ViewData["TypeofRoom"] = TypeofRoomfromDb;

          

            HotelVM hmv = new HotelVM();

            //hmv.HotelMasters = GetHotelMaster();

           // hmv.HotelBookings = GetHotelBookings();

            return View(hmv);

            //return View(db.HotelMasters.Where(x => x.Name.Contains(search)).ToList());

            //return RedirectToAction("Index");

        }

 

        [HttpPost]

        [ValidateAntiForgeryToken]

        public ActionResult Index([Bind(Include = "ID,City,HotelName,StarRating,HotelCode,Address")] HotelVM hotelVM)

        {

            if (ModelState.IsValid)

            {

               // db.Entry(HotelVM).State = EntityState.Modified;

                db.SaveChanges();

                return RedirectToAction("GetHotel");

            }

            return View("Index");

        }

 

      

        // GET: HotelBookings1/Edit/5

        public ActionResult Select(int? id)

        {

            if (id == null)

            {

                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            }

            HotelBooking hotelBooking = db.HotelBookings.Find(id);

            if (hotelBooking == null)

            {

                return HttpNotFound();

            }

            return View(hotelBooking);

        }

 

        // POST: HotelBookings1/Edit/5

        // To protect from overposting attacks, enable the specific properties you want to bind to, for

        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.

        [HttpPost]

        [ValidateAntiForgeryToken]

        public ActionResult Select([Bind(Include = "ID,Date,HotelName,HotelCode,RoomType,Tariff,NumberOfRooms,Contact,CheckIn,CheckOut")] HotelBooking hotelBooking)

        {

            if (ModelState.IsValid)

            {

                db.Entry(hotelBooking).State = EntityState.Modified;

                db.SaveChanges();

                return RedirectToAction("BookingConfirm");

            }

            return View(hotelBooking);

        }

        public ActionResult BookingConfirm()

        {

            return View(db.HotelBookings.ToList());

        }

    }

} 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.Data.Entity;

using System.Linq;

using System.Net;

using System.Web;

using System.Web.Mvc;

using WebAppl1.DAL.Data;

using WebAppl1.Hotel.ViewModel;

using WebAppl1.Model.Models;

 

namespace WebAppl1.Hotel.Controllers

{

    public class HotelVMController : Controller

    {

        private ApplicationDbContext db = new ApplicationDbContext();

        // GET: HotelVM

       

        public ActionResult GetHotel()

        {

            return View(db.HotelMasters.ToList());

        }

        public ActionResult Index()

        {

           

                var CitiesfromDb = new SelectList(db.HotelMasters.ToList(), "ID", "City");

                var NoOfRoomfromDb = new SelectList(db.HotelBookings.ToList(), "ID", "NumberOfRooms");

                var TypeofRoomfromDb = new SelectList(db.HotelBookings.ToList(), "ID", "RoomType");

                ViewData["Cities"] = CitiesfromDb;

                ViewData["NoOfRoom"] = NoOfRoomfromDb;

                ViewData["TypeofRoom"] = TypeofRoomfromDb;

          

            HotelVM hmv = new HotelVM();

            //hmv.HotelMasters = GetHotelMaster();

           // hmv.HotelBookings = GetHotelBookings();

            return View(hmv);

            //return View(db.HotelMasters.Where(x => x.Name.Contains(search)).ToList());

            //return RedirectToAction("Index");

        }

 

        [HttpPost]

        [ValidateAntiForgeryToken]

        public ActionResult Index([Bind(Include = "ID,City,HotelName,StarRating,HotelCode,Address")] HotelVM hotelVM)

        {

            if (ModelState.IsValid)

            {

               // db.Entry(HotelVM).State = EntityState.Modified;

                db.SaveChanges();

                return RedirectToAction("GetHotel");

            }

            return View("Index");

        }

 

      

        // GET: HotelBookings1/Edit/5

        public ActionResult Select(int? id)

        {

            if (id == null)

            {

                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            }

            HotelBooking hotelBooking = db.HotelBookings.Find(id);

            if (hotelBooking == null)

            {

                return HttpNotFound();

            }

            return View(hotelBooking);

        }

 

        // POST: HotelBookings1/Edit/5

        // To protect from overposting attacks, enable the specific properties you want to bind to, for

        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.

        [HttpPost]

        [ValidateAntiForgeryToken]

        public ActionResult Select([Bind(Include = "ID,Date,HotelName,HotelCode,RoomType,Tariff,NumberOfRooms,Contact,CheckIn,CheckOut")] HotelBooking hotelBooking)

        {

            if (ModelState.IsValid)

            {

                db.Entry(hotelBooking).State = EntityState.Modified;

                db.SaveChanges();

                return RedirectToAction("BookingConfirm");

            }

            return View(hotelBooking);

        }

        public ActionResult BookingConfirm()

        {

            return View(db.HotelBookings.ToList());

        }

    }

}

===========================================================================================

@model WebAppl1.Hotel.ViewModel.HotelVM

 

@{

    ViewBag.Title = "Search";

}

 

<h2>Search</h2>

 

 

@using (Html.BeginForm())

{

    @Html.AntiForgeryToken()

 

    <div class="form-horizontal">

        <h4>HotelBooking</h4>

        <hr />

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

 

        <div class="form-group">

            @Html.LabelFor(model => model.HotelMasters.City, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.DropDownList("HotelMaster", (IEnumerable<SelectListItem>)ViewData["Cities"])

                @*@Html.EditorFor(model => model.HotelMasters.City, new { htmlAttributes = new { @class = "form-control" } })*@

                @*@Html.DropDownList("City", new List<SelectListItem>

        {

            new SelectListItem{ Text="---------   Please Select City  ------------", Value="0"},

            new SelectListItem{ Text="Patna", Value="1"},

            new SelectListItem{ Text="Ranchi", Value="2"},

           

        })*@

                @Html.ValidationMessageFor(model => model.HotelMasters.City, "", new { @class = "text-danger" })

            </div>

        </div>

 

 

        <div class="form-group">

                @Html.LabelFor(model => model.HotelBookings.CheckIn, htmlAttributes: new { @class = "control-label col-md-2" })

                <div class="col-md-10">

                    @Html.EditorFor(model => model.HotelBookings.CheckIn, new { htmlAttributes = new { @class = "datepicker" } })

                    @Html.ValidationMessageFor(model => model.HotelBookings.CheckIn, "", new { @class = "text-danger" })

                </div>

            </div>

 

            <div class="form-group">

                @Html.LabelFor(model => model.HotelBookings.CheckOut, htmlAttributes: new { @class = "control-label col-md-2" })

                <div class="col-md-10">

                    @Html.EditorFor(model => model.HotelBookings.CheckOut, new { htmlAttributes = new { @class = "datepicker" } })

                    @Html.ValidationMessageFor(model => model.HotelBookings.CheckOut, "", new { @class = "text-danger" })

                </div>

            </div>

        <div class="form-group">

            @Html.LabelFor(model => model.HotelBookings.RoomType, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.DropDownList("HotelBookings", (IEnumerable<SelectListItem>)ViewData["TypeofRoom"])

                @*@Html.EditorFor(model => model.RoomType, new { htmlAttributes = new { @class = "form-control" } })*@

                @*@Html.DropDownList("RoomType", new List<SelectListItem>

          {

              new SelectListItem{ Text="------ Please Select Room Type ----------", Value="0"},

              new SelectListItem{ Text="Single", Value="1"},

              new SelectListItem{ Text="Double", Value="2"},

              new SelectListItem{ Text="Twin", Value="3"}

          })*@

                @Html.ValidationMessageFor(model => model.HotelBookings.RoomType, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.HotelBookings.NumberOfRooms, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

           @Html.DropDownList("HotelBookings", (IEnumerable<SelectListItem>)ViewData["NoOfRoom"])

                @*@Html.EditorFor(model => model.NumberOfRooms, new { htmlAttributes = new { @class = "form-control" } })*@

                @*@Html.DropDownList("NumberOfRooms", new List<SelectListItem>

        {

            new SelectListItem{ Text="-------- Please Select Number Of Rooms -------------", Value="0"},

            new SelectListItem{ Text="1", Value="1"},

            new SelectListItem{ Text="2", Value="2"},

            new SelectListItem{ Text="3", Value="3"},

 

        })*@

                @Html.ValidationMessageFor(model => model.HotelBookings.NumberOfRooms, "", new { @class = "text-danger" })

            </div>

        </div>

 

 

 

 

        <div class="form-group">

            <div class="col-md-offset-2 col-md-10">

                <input type="submit" value="Search" class="btn btn-success" />

            </div>

        </div>

    </div>

}

 

<div>

    @Html.ActionLink("Back to List", "Index")

</div>

<link href="~/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />

@section Scripts {

    <script src="~/Scripts/jquery-ui-1.13.2.min.js"></script>

    @Scripts.Render("~/bundles/jqueryval")

    <script>

        $(document).ready(function () {

            $(".datepicker").datepicker(

                {

                dateFormat: "dd-mm-yy",

                minDate: 'today',

                changemonth: true,

                changeyear: true

                }

 

            );

        });

    </script>

}

============================

@model IEnumerable<WebAppl1.Model.Models.HotelMaster>

 

@{

    ViewBag.Title = "GetHotel";

}

@*<label>Date:</label>

<label>@DateTime.Now</label>*@

<p>

    @Html.ActionLink("Create New", "Create")

</p>

<table class="table">

    <tr>

        <th>

            @Html.DisplayNameFor(model => model.City)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.HotelName)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.StarRating)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.HotelCode)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.Address)

        </th>

        <th></th>

    </tr>

 

    @foreach (var item in Model)

    {

        <tr>

            <td>

                @Html.DisplayFor(modelItem => item.City)

            </td>

            <td>

                @Html.DisplayFor(modelItem => item.HotelName)

            </td>

            <td>

                @Html.DisplayFor(modelItem => item.StarRating)

            </td>

            <td>

                @Html.DisplayFor(modelItem => item.HotelCode)

            </td>

            <td>

                @Html.DisplayFor(modelItem => item.Address)

            </td>

            <td>

                @Html.ActionLink("Select", "Select", new { id = item.ID })

            </td>

        </tr>

    }

 

</table>

====================================================

@model WebAppl1.Model.Models.HotelBooking

 

@{

    ViewBag.Title = "Select";

}

 

<h2>Select</h2>

 

@using (Html.BeginForm())

{

    @Html.AntiForgeryToken()

   

    <div class="form-horizontal">

        <h4>HotelBooking</h4>

        <hr />

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form-group">

            @Html.LabelFor(model => model.Date, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.Date, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.HotelName, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.HotelName, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.HotelName, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.HotelCode, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.HotelCode, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.HotelCode, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.RoomType, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.RoomType, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.RoomType, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.Tariff, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.Tariff, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.Tariff, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.NumberOfRooms, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.NumberOfRooms, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.NumberOfRooms, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.Contact, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.Contact, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.Contact, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.CheckIn, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.CheckIn, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.CheckIn, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            @Html.LabelFor(model => model.CheckOut, htmlAttributes: new { @class = "control-label col-md-2" })

            <div class="col-md-10">

                @Html.EditorFor(model => model.CheckOut, new { htmlAttributes = new { @class = "form-control" } })

                @Html.ValidationMessageFor(model => model.CheckOut, "", new { @class = "text-danger" })

            </div>

        </div>

 

        <div class="form-group">

            <div class="col-md-offset-2 col-md-10">

                <input type="submit" value="Book" class="btn btn-default" />

            </div>

        </div>

    </div>

}

 

<div>

    @Html.ActionLink("Back to List", "Index")

</div>

============================================

@model IEnumerable<WebAppl1.Model.Models.HotelBooking>

 

@{

    ViewBag.Title = "BookingConfirm";

}

 

<h2>BookingConfirm</h2>

 

@*<p>

    @Html.ActionLink("Create New", "Create")

</p>*@

<table class="table">

    <tr>

        <th>

            <label>Date</label>

        </th>@*<th>

            @Html.DisplayNameFor(model => model.Date)

        </th>*@

        <th>

            @Html.DisplayNameFor(model => model.HotelName)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.HotelCode)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.RoomType)

        </th>

        @*<th>

            @Html.DisplayNameFor(model => model.Tariff)

        </th>*@

        <th>

            @Html.DisplayNameFor(model => model.NumberOfRooms)

        </th>

        @*<th>

            @Html.DisplayNameFor(model => model.Contact)

        </th>*@

        <th>

            @Html.DisplayNameFor(model => model.CheckIn)

        </th>

        <th>

            @Html.DisplayNameFor(model => model.CheckOut)

        </th>

        <th></th>

    </tr>

 

@foreach (var item in Model) {

    <tr>

        <td>

           <label>@DateTime.Now</label>

        </td>

        @*<td>

            @Html.DisplayFor(modelItem => item.Date)

        </td>*@

        <td>

            @Html.DisplayFor(modelItem => item.HotelName)

        </td>

        <td>

            @Html.DisplayFor(modelItem => item.HotelCode)

        </td>

        <td>

            @Html.DisplayFor(modelItem => item.RoomType)

        </td>

        @*<td>

            @Html.DisplayFor(modelItem => item.Tariff)

        </td>*@

        <td>

            @Html.DisplayFor(modelItem => item.NumberOfRooms)

        </td>

        @*<td>

            @Html.DisplayFor(modelItem => item.Contact)

        </td>*@

        <td>

            @Html.DisplayFor(modelItem => item.CheckIn)

        </td>

        <td>

            @Html.DisplayFor(modelItem => item.CheckOut)

        </td>

        @*<td>

            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |

            @Html.ActionLink("Details", "Details", new { id=item.ID }) |

            @Html.ActionLink("Delete", "Delete", new { id=item.ID })

        </td>*@

    </tr>

}

 

</table>

==================================================================

using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

using System.Linq;

using System.Web;

 

namespace WebAppl1.Model.Models

{

    public class HotelBooking

    {

        [Key]

        public int ID { get; set; }

        public Nullable<System.DateTime> Date { get; set; }

 

        [Display(Name = "Hotel Name")]

        public string HotelName { get; set; }

 

        [Display(Name = "Hotel Code")]

        public string HotelCode { get; set; }

 

        [Display(Name = "Type Of Rooms")]

        public string RoomType { get; set; }

        public Nullable<decimal> Tariff { get; set; }

 

        [Display(Name = "Number Of Rooms")]

        public Nullable<int> NumberOfRooms { get; set; }

        public string Contact { get; set; }

        public Nullable<System.DateTime> CheckIn { get; set; }

        public Nullable<System.DateTime> CheckOut { get; set; }

    }

}

+++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

using System.Linq;

using System.Web;

 

namespace WebAppl1.Model.Models

{

    public class HotelMaster

    {

        [Key]

        public int ID { get; set; }

 

        //[Index(IsUnique = true)]

        public string City { get; set; }

 

        [Display(Name = "Hotel Name")]

        public string HotelName { get; set; }

        public Nullable<int> StarRating { get; set; }

 

        [Display(Name = "Hotel Code")]

        public string HotelCode { get; set; }

        public string Address { get; set; }

    }

}

++++++++++++++++++++++++++++++++++++++++++++

using System;

using System.Collections.Generic;

using System.ComponentModel.DataAnnotations;

using System.Linq;

using System.Web;

 

namespace WebAppl1.Model.Models

{

    public class HotelRoom

    {

        [Key]

        public int ID { get; set; }

 

        [Display(Name = "Type Of Rooms")]

        public string RoomType { get; set; }

        public Nullable<decimal> Tariff { get; set; }

 

        [Display(Name = "Hotel Code")]

        public string HotelCode { get; set; }

    }

}

  

 

 

 

Asp.net mvc framework code 1st approach using n-tier architecture(Repository Pattern) Asp.net mvc framework code 1st approach using n-tier architecture(Repository Pattern) Reviewed by Rikesh on August 03, 2023 Rating: 5

No comments:

Powered by Blogger.