示例#1
0
        public IActionResult CreateSaved(Pricetranfer pricetranfer)
        {
            StatusQuery Notification;

            if (ModelState.IsValid)
            {
                try
                {
                    _pricetranfer.Insert(pricetranfer);
                    var statusInsert = _pricetranfer.SaveChanges();
                    if (statusInsert > 0)
                    {
                        TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("success", "", "Thêm thành công"));
                        return(RedirectToAction("Index", "Tranfer"));
                    }
                    else
                    {
                        Notification   = new StatusQuery("error", "", "Thêm mới thất bại");
                        ViewBag.Status = Notification.Status;
                        ViewBag.Value  = Notification.Value;
                        ViewBag.Type   = Notification.Type;
                    }
                }
                catch (Exception)
                {
                    return(View(pricetranfer));
                }
            }
            else
            {
                return(View(pricetranfer));
            }
            return(View(pricetranfer));
        }
示例#2
0
        public ActionResult EditSaved(Pricetranfer model)
        {
            var _pricetranferedit = _pricetranfer.GetById(model.Id);

            _pricetranferedit.Id        = model.Id;
            _pricetranferedit.Name      = model.Name;
            _pricetranferedit.PriceBuy  = model.PriceBuy;
            _pricetranferedit.PriceSell = model.PriceSell;
            _pricetranferedit.Ovr       = model.Ovr;
            _pricetranferedit.Image     = model.Image;
            var statusEdit = _pricetranfer.SaveChanges();

            if (statusEdit > 0)
            {
                TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("success", "", "Sửa thành công"));
                return(RedirectToAction("Index", "Tranfer"));
            }
            return(View(_pricetranferedit));
        }