public ActionResult Create(FormCollection formCollection, HotwordViewModel vo) { if (ModelState.IsValid) { if (vo.Type == (int)HotWordType.BrandStruct) { vo.BrandName = _brandRepo.Find(vo.BrandId).Name; } else if (vo.Type == (int)HotWordType.Stores) { vo.StoreName = _storeRepo.Find(vo.StoreId).Name; } var entity = vo.ToEntity <HotWordEntity>(); entity.CreatedUser = base.CurrentUser.CustomerId; entity.CreatedDate = DateTime.Now; entity.UpdatedUser = base.CurrentUser.CustomerId; entity.UpdatedDate = DateTime.Now; _hotwordRepo.Insert(entity); return(RedirectToAction("Edit", new { Id = entity.Id })); } return(View(vo)); }
public ActionResult Create(FormCollection formCollection, HotwordViewModel vo) { if (ModelState.IsValid) { if (vo.Type == (int)HotWordType.BrandStruct) { vo.BrandName = _brandRepo.Find(vo.BrandId).Name; } else if (vo.Type == (int)HotWordType.Stores) { vo.StoreName = _storeRepo.Find(vo.StoreId).Name; } var entity = vo.ToEntity<HotWordEntity>(); entity.CreatedUser = base.CurrentUser.CustomerId; entity.CreatedDate = DateTime.Now; entity.UpdatedUser = base.CurrentUser.CustomerId; entity.UpdatedDate = DateTime.Now; _hotwordRepo.Insert(entity); return RedirectToAction("Edit", new { Id = entity.Id}); } return View(vo); }
public ActionResult Edit(FormCollection formCollection, HotwordViewModel vo) { if (ModelState.IsValid) { var entity = _hotwordRepo.Find(vo.Id); if (entity == null) throw new ApplicationException("entity not exists!"); entity.SortOrder = vo.SortOrder; entity.Status = vo.Status; entity.Type = vo.Type; entity.UpdatedDate = DateTime.Now; entity.UpdatedUser = CurrentUser.CustomerId; entity.Word = vo.Word; if (entity.Type == (int)HotWordType.BrandStruct) { vo.BrandName = _brandRepo.Find(vo.BrandId).Name; entity.Word = vo.BrandString; } else if (entity.Type == (int)HotWordType.Stores) { vo.StoreName = _storeRepo.Find(vo.StoreId).Name; entity.Word = vo.StoreString; } _hotwordRepo.Update(entity); return RedirectToAction("List"); } return View(vo); }