Example #1
0
 public ActionResult Create(BrandModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = model.MapTo <Brand>();
         _brandService.InsertBrand(entity);
         return(RedirectToAction("List"));
     }
     return(View(model));
 }
Example #2
0
 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));
 }
Example #3
0
        /// <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>());
 }