예제 #1
0
 public ActionResult ModelBinding()
 {
     var customer = new Customer()
         {
             Addresses = new List<Address>
                 {
                     new Address {AddressId = 1, Number = "1", Street = "one"},
                     new Address {AddressId = 2, Number = "2", Street = "two"}
                 }
         };
     return View(customer);
 }
 public CustomerRepresentation Get(int customerId)
 {
     //customerRepository.GetById(customerId)
     var customer = new Customer
         {
             CustomerId = customerId,
             Title = "title",
             FirstName = "first Name",
             Surname = "surname"
         };
     return CustomerRepresentation.FromResource(customer);
 }
예제 #3
0
파일: CrmBLL.cs 프로젝트: liuyouying/MVC
 public static void SaveCustomer(Customer customer)
 {
     using (var dbContext = new CrmEntities()){
         if(customer.ID > 0){
             if(dbContext.Customer.Any(c => c.Tel == customer.Tel && c.ID != customer.ID))
                 throw new Exception("已存在此电话的客户!");
             if(dbContext.Customer.Any(c => c.Number == customer.Number && c.ID != customer.ID))
                 throw new Exception("已存在此编号的客户!");
         }
         else{
             if(dbContext.Customer.Any(c => c.Tel == customer.Tel))
                 throw new Exception("已存在此电话的客户!");
             if(dbContext.Customer.Any(c => c.Number == customer.Number))
                 throw new Exception("已存在此编号的客户!");
             dbContext.Customer.Add(customer);
         }
         dbContext.SaveChanges();
     }
 }
예제 #4
0
        public ActionResult ModelBinding(Customer customer)
        {
            var test = customer.FirstName;

            return View(customer);
        }
예제 #5
0
 public ActionResult Index(Customer customer)
 {
     return View(customer);
 }