Пример #1
0
        public JsonResult UpdateVendor(EResVendorViewModel viewModel)
        {
            bool   bReturn = false;
            string message = "failed";

            EResVendor myVendor = _db.EResVendors.Find(viewModel.VendorID);

            if (myVendor != null)
            {
                myVendor.VendorName = viewModel.VendorName;

                try
                {
                    _db.SaveChanges();

                    bReturn = true;
                    message = "success";
                }
                catch (InvalidOperationException ex)
                {
                    message = ex.Message;
                }
            }

            return(Json(new
            {
                Success = bReturn,
                Message = message,
                SelectList = _db.EResVendorsDropdown()
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult CreateVendor(EResVendorViewModel viewModel)
        {
            bool   bReturn = false;
            string message = "failed";

            EResVendor newVendor = new EResVendor()
            {
                VendorName = viewModel.VendorName
            };

            if (_db.EResVendors.Add(newVendor) != null)
            {
                if (_db.SaveChanges() > 0)
                {
                    bReturn = true;
                    message = "success";
                }
            }

            return(Json(new
            {
                Success = bReturn,
                Message = message,
                SelectList = _db.EResVendorsDropdown()
            }, JsonRequestBehavior.AllowGet));
        }