Example #1
0
        //// GET: Setting
        //public ActionResult Index()
        //{
        //    return View();
        //}

        public ActionResult Index(int id)
        {
            var setting = _customerSettingRepository.Get(s => s.Customer.CustomerId == id);
            var vm = _mapper.Mapper.Map<CustomerSettingFormModel>(setting);
            if (vm == null) vm = new CustomerSettingFormModel() { CustomerId = id };
            return View(vm);
        }
Example #2
0
        public ActionResult Save(CustomerSettingFormModel fm)
        {
            if (ModelState.IsValid)
            {
                var command = _mapper.Mapper.Map<CreateOrUpdateCustomerSettingCommand>(fm);
                command.Customer = _customerRepository.GetById(fm.CustomerId);
                //IEnumerable<ValidationResult> errors = _commandBus.Validate(command);
                //ModelState.AddModelErrors(errors);
                if (ModelState.IsValid)
                {
                    var result = _commandBus.Submit(command);
                    if (result.Success) return RedirectToAction("Index", new { id = fm.CustomerId });
                }
            }

            return View(fm.CustomerSettingId == 0 ? "Create" : "Edit", fm);
        }
Example #3
0
 public ActionResult Create(int id)
 {
     var customer = _customerRepository.GetById(id);
     var vm = new CustomerSettingFormModel { CustomerId = customer.CustomerId, CustomerName = customer.Name };
     return View(vm);
 }