Hiện giờ mình đang mắc vấn đề này mong mọi người giúp đỡ........
và mình cần hỏi các vấn đề liên quan :
1, phải tạo model như thế nào 1 hay 2 model cho view và add khác nhau hay dùng chung 1 model
đây là đoạn code model của mục view của mình
Mã:
public string TourName { get; set; }
public DateTime DepartureDay { get; set; }
public string DeparturePosition { get; set; }
public int AvailableRoom { get; set; }
public BookingViewModels(string tourname, DateTime departureday,string departureposition, int availableroom)
{
this.TourName = tourname; this.DepartureDay = departureday; this.DeparturePosition = departureposition; this.AvailableRoom = availableroom;
}
2,bên phần controller thì nên làm như thế nào
còn đây là phần controller của mục view của mình
Mã:
public ActionResult TourBooking(string strID, Booking addbooking)
{
var id_tour = (from db in _data.Tours
//join db2 in _data.Bookings on db.ID_Tour equals db2.ID_Tour
where db.ID_Tour == strID
//&& db2.ID_Tour == db.ID_Tour
select new
{
db.TourName,
db.DepartureDay,
db.DeparturePosition,
db.AvailableRoom,
}).FirstOrDefault();
var view_tour = new BookingViewModels(id_tour.TourName, Convert.ToDateTime(id_tour.DepartureDay), id_tour.DeparturePosition, Convert.ToInt32(id_tour.AvailableRoom));
return View(view_tour);
}
còn đây là phần model các thuộc tính cần Add của bảng thứ 2
Mã:
public class BookingAddModels
{
public string ID_Booking { get; set; }
public string CompanyName { get; set; }
public string OrdererName { get; set; }
public string IDcardNo { get; set; }
public string Address { get; set; }
public int PhoneNumber { get; set; }
public string Email { get; set; }
public string TaxCode { get; set; }
public int TotalOfTourist { get; set; }
public int Adult { get; set; }
public int Children { get; set; }
public int Baby { get; set; }
public DateTime BookingDay { get; set; }
public DateTime PaymentDay { get; set; }
public decimal TotalOfCost { get; set; }
public string PaymentMethod { get; set; }
public string ID_Tour { get; set; }
}
mong mọi người giúp đỡ đề án sắp đến hạn T.T ko bit bao giờ xong T.T...........
View more random threads:
Vòng tay phong thủy là một vật phẩm mang lại sự may mắn trong tài lộc, tình duyên, sự nghiệp,.. Là một vật phẩm không xa lạ gì với chúng ta, vòng tay phong thủy có nhiều màu, đa dạng và mỗi màu sắc...
Ý nghĩa và cách phân loại vòng tay...