public ViewResult ViewMoto() { MotoViewModel obj = new MotoViewModel(); obj.allMoto = _allMoto.Motos; obj.currCategory = ""; return(View(obj)); }
public ActionResult EditMoto(MotoViewModel model, HttpPostedFileBase[] files) { if (ModelState.IsValid) { Mapper.CreateMap <MotoViewModel, moto>(); var entity = Mapper.Map <MotoViewModel, moto>(model); _articleService.Update(entity); addResources(model.id, files); } return(RedirectToAction("moto", new { id = model.id })); }
public ActionResult CreateMoto(MotoViewModel model, HttpPostedFileBase[] files) { int article_id = 0; if (ModelState.IsValid) { var customer = _customerService.getCustomerById(model.customer_id); if (customer == null) { throw new InvalidOperationException("Cliente no encontrado"); } Mapper.CreateMap <MotoViewModel, moto>(); var entity = Mapper.Map <MotoViewModel, moto>(model); article_id = _articleService.Create(entity); addResources(article_id, files); } return(RedirectToAction("moto", new { id = article_id })); }