示例#1
0
        public ActionResult Edit(CustomerRoleModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var customerRole = model.MapTo <CustomerRole>();
                _roleService.UpdateCustomerRole(customerRole);

                if (continueEditing)
                {
                    return(RedirectToAction("Edit", new { id = customerRole.Id }));
                }
                return(RedirectToAction("List"));
            }

            PrepareCustomerRoleModel(model);
            return(View(model));
        }
示例#2
0
        public ActionResult Create(CustomerRoleModel model, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                //这里就是页面实体映射的关键,我可以把页面的实体转换为数据库的实体在进行操作
                //但是还需要一小步在web项目中的App_Start文件夹中有个Blog_SolutionWebModule类,我们要注意下
                //去看看就知道了
                var entity = model.MapTo <CustomerRole>();
                _roleService.InsertCustomerRole(entity);
                if (continueEditing)
                {
                    return(RedirectToAction("Edit", new { id = entity.Id }));
                }
                return(RedirectToAction("List"));
            }

            PrepareCustomerRoleModel(model);
            return(View(model));
        }
 public static CustomerRole ToEntity(this CustomerRoleModel model, CustomerRole destination)
 {
     return(model.MapTo(destination));
 }
 public static CustomerRole ToEntity(this CustomerRoleModel model)
 {
     return(model.MapTo <CustomerRoleModel, CustomerRole>());
 }