// GET: /PlanoLoja/PlanoLojaCreate public ActionResult PlanoLojaCreate() { PlanoLoja planoloja = new PlanoLoja(); #region populaobjetos var planos = _planoAppService.Find(t => t.STATUS == "A"); IEnumerable<SelectListItem> planosSelectListItem = new SelectList(planos, "ID_PLANO", "DESC_PLANO"); ViewBag.ID_PLANO = new SelectList(planos, "ID_PLANO", "DESC_PLANO"); var lojas = _lojaAppService.Find(t => t.CodigoLojaAlternate.Trim() != "-2" && t.CodigoLojaAlternate.Trim() != "-1"); ; IEnumerable<SelectListItem> lojasSelectListItem = new SelectList(lojas, "CodigoLojaAlternate", "NomeLoja"); ViewBag.CODIGOLOJAALTERNATE = new SelectList(lojas, "CodigoLojaAlternate", "NomeLoja"); #endregion populaobjetos PlanoLojaViewModel planoLojaVM = new PlanoLojaViewModel(planoloja, planosSelectListItem, lojasSelectListItem); return View(planoLojaVM); }
// GET: /PlanoLoja/PlanoLojaEdit/5 public ActionResult PlanoLojaEdit(int? id) { if (id == null) { //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); throw new Exception(); } var planoloja = _planolojaAppService.Get(id ?? default(int)); if (planoloja == null) { //return HttpNotFound(); throw new Exception(); } #region populaobjetos var planos = _planoAppService.All(); IEnumerable<SelectListItem> planosSelectListItem = new SelectList(planos, "ID_PLANO", "DESC_PLANO"); ViewBag.ID_PLANO = new SelectList(planos, "ID_PLANO", "DESC_PLANO", planoloja.ID_PLANO); var lojas = _lojaAppService.Find(t => t.CodigoLojaAlternate.Trim() != "-2" && t.CodigoLojaAlternate.Trim() != "-1"); IEnumerable<SelectListItem> lojasSelectListItem = new SelectList(lojas, "CodigoLojaAlternate", "NomeLoja"); ViewBag.CODIGOLOJAALTERNATE = new SelectList(lojas, "CodigoLojaAlternate", "NomeLoja", planoloja.CODIGOLOJAALTERNATE); #endregion populaobjetos PlanoLojaViewModel planoLojaVM = new PlanoLojaViewModel(planoloja, planosSelectListItem, lojasSelectListItem); return View(planoLojaVM); }
// // GET: /PlanoLoja/PlanoLojaDelete/5 public ActionResult PlanoLojaDelete(int? id, bool? saveChangesError = false) { if (id == null) { //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //throw new InvalidOperationException("Something very bad happened while doing important stuff"); throw new Exception(); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Erro na exclusão. Tente novamente ou, se o problema persistir, entre em contato com o suporte."; } var planoloja = _planolojaAppService.Get(id ?? default(int)); if (planoloja == null) { //return HttpNotFound(); throw new Exception(); } //return View(planoloja); Loja loja = _lojaAppService.Find(t => t.CodigoLojaAlternate == planoloja.CODIGOLOJAALTERNATE).FirstOrDefault(); PlanoLojaViewModel categoriaPercentualVM = new PlanoLojaViewModel(planoloja, loja); return View(categoriaPercentualVM); }