コード例 #1
0
        public JsonResult SaveData(ViewModel.CustomerViewModel model)
        {
            var result = false;

            try
            {
                if (model.Id > 0)
                {
                    var customer = dbContext.Customers.FirstOrDefault(x => x.CustomerId == model.Id);
                    customer.Name    = model.Name;
                    customer.Age     = model.Age;
                    customer.Address = model.Address;
                    dbContext.SaveChanges();
                    result = true;
                }
                else
                {
                    Customer customer = new Customer();
                    customer.Name    = model.Name;
                    customer.Age     = model.Age;
                    customer.Address = model.Address;
                    dbContext.Customers.Add(customer);
                    dbContext.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
 public RadForm1()
 {
     InitializeComponent();
     Ref_ProductViewModel         = new ViewModel.ProductViewModel();
     Ref_ProductCategoryViewModel = new ViewModel.ProductCategoryViewModel();
     Ref_CustomerViewModel        = new ViewModel.CustomerViewModel();
     Ref_OrderMasterViewModel     = new ViewModel.OrderMasterViewModel();
 }