public async System.Threading.Tasks.Task <ActionResult> Add(Models.BrandDetailVM model) { if (ModelState.IsValid) { var brand = new Data.Models.Entities.Brand { BrandName = model.Name, Description = model.Description, }; await this.brandService.CreateAsync(brand); return(this.RedirectToAction("Index")); } return(View("Form", model)); }
public JsonResult GetBrands() { var brands = this.brandService.Get().ToList(); var brandVMs = new List <Models.BrandDetailVM>(); foreach (var item in brands) { var b = new Models.BrandDetailVM { Name = item.BrandName, Description = item.Description, }; brandVMs.Add(b); } return(Json(brandVMs)); }
// GET: Brand/Form/:id public ActionResult Form(int?id) { Models.BrandDetailVM model = null; if (id != null) { var brand = this.brandService.Get(id); if (brand != null) { model = new Models.BrandDetailVM { Name = brand.BrandName, Description = brand.Description, Id = brand.BrandID, isActive = brand.isActive, }; } } return(View(model)); }
public static List <Models.BrandDetailVM> GetBrandList() { IBrandService brandService = DependencyUtils.Resolve <IBrandService>(); var brands = brandService.Get().ToList(); var brandVMs = new List <Models.BrandDetailVM>(); foreach (var item in brands) { var b = new Models.BrandDetailVM { Name = item.BrandName, Description = item.Description, Id = item.BrandID, isActive = item.isActive, }; brandVMs.Add(b); } return(brandVMs); }
public async System.Threading.Tasks.Task <ActionResult> Update(Models.BrandDetailVM model) { if (ModelState.IsValid) { var brand = this.brandService.Get(model.Id); if (brand != null) { brand.BrandName = model.Name; brand.Description = model.Description; brand.isActive = model.isActive; } await this.brandService.UpdateAsync(brand); Session.Clear(); Session["UPDATE_RESULT"] = true; return(new ContentResult { Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Brand")), ContentType = "text/html" }); } return(View("Form", model)); }
public async System.Threading.Tasks.Task <ActionResult> Add(Models.BrandDetailVM model) { if (ModelState.IsValid) { var brand = new Data.Models.Entities.Brand { BrandName = model.Name, Description = model.Description, isActive = model.isActive }; await this.brandService.CreateAsync(brand); //return this.RedirectToAction("Index"); Session.Clear(); Session["ADD_RESULT"] = true; return(new ContentResult { Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Brand")), ContentType = "text/html" }); } return(View("Form", model)); }