コード例 #1
0
 public ActionResult Bill()
 {
     using (DataContext db = new DataContext())
     {
         var cus = (from c in db.Customers
                    join r in db.Roles on c.role equals r.Role_ID
                    where c.Customer_ID == SessionCheckingCustomes.customerID
                    select new
         {
             c.Customer_ID,
             c.customerName,
             c.customerAddress,
             c.customerEmail,
             c.customerPhone
         }).ToList();
         List <CusIndex_ViewModels> customer = new List <CusIndex_ViewModels>();
         foreach (var c in cus)
         {
             CusIndex_ViewModels ci = new CusIndex_ViewModels();
             ci.cus_id     = c.Customer_ID;
             ci.cusName    = c.customerName;
             ci.cusAddress = c.customerAddress;
             ci.cusEmail   = c.customerEmail;
             ci.cusPhone   = c.customerPhone;
             customer.Add(ci);
         }
         return(View(customer));
     }
 }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: mobpyschi/Bookweb
 public ActionResult CustomersIndex()
 {
     using (DataContext db = new DataContext())
     {
         var cus = (from c in db.Customers
                    join r in db.Roles on c.role equals r.Role_ID
                    select new
         {
             c.Customer_ID,
             c.customerName,
             c.customerAddress,
             c.avatar,
             c.customerEmail,
             c.customerPhone,
             c.sex,
             r.roleName
         }).ToList();
         List <CusIndex_ViewModels> customer = new List <CusIndex_ViewModels>();
         foreach (var c in cus)
         {
             CusIndex_ViewModels ci = new CusIndex_ViewModels();
             ci.cus_id     = c.Customer_ID;
             ci.cusName    = c.customerName;
             ci.cusAddress = c.customerAddress;
             ci.avatar     = c.avatar;
             ci.cusEmail   = c.customerEmail;
             ci.cusPhone   = c.customerPhone;
             ci.sex        = c.sex;
             ci.role       = c.roleName;
             customer.Add(ci);
         }
         return(View(customer));
     }
 }