public ActionResult Create(BrandModel model) { if (ModelState.IsValid) { var entity = model.MapTo <Brand>(); _brandService.InsertBrand(entity); return(RedirectToAction("List")); } return(View(model)); }
public ActionResult Edit(BrandModel model) { if (ModelState.IsValid) { var entity = _brandService.GetBrandById(model.Id); entity = model.MapTo <BrandModel, Brand>(entity); _brandService.UpdateBrand(entity); return(RedirectToAction("List")); } return(View(model)); }
/// <summary> /// TODO: /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <bool> SaveBrand(BrandModel model) { var entity = model.MapTo <Brand>(); if (model.Id < 1) { await _brandRepository.Insert(entity); } else { await _brandRepository.Update(entity); } return(true); }
public static Brand ToEntity(this BrandModel model, Brand destination) { return(model.MapTo(destination)); }
public static Brand ToEntity(this BrandModel model) { return(model.MapTo <BrandModel, Brand>()); }