예제 #1
0
        public ActionResult Create([Bind(Include = "Product, GrantDecision, Amount")] Grant grant)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    GrantServices.Insert(CurrentUser.Id, grant, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.GrantDecisionList = new SelectList(GrantDecisionServices.List(db), "Id", "CersNumber");
            ViewBag.ProductList       = new SelectList(ProductServices.List(db), "Id", "Notes");
            return(View(grant));
        }
예제 #2
0
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.GrantDecisionList = new SelectList(GrantDecisionServices.List(db), "Id", "CersNumber");
            ViewBag.ProductList       = new SelectList(ProductServices.List(db), "Id", "Notes");
            return(View());
        }
예제 #3
0
        // GET: Grant/Edit/5
        public ActionResult Edit(Nullable <int> product)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (product == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Grant grant = GrantServices.Get(product.Value, db);

            if (grant == null)
            {
                return(HttpNotFound());
            }

            ViewBag.GrantDecisionList = new SelectList(GrantDecisionServices.List(db), "Id", "CersNumber", grant.GrantDecision);
            ViewBag.ProductList       = new SelectList(ProductServices.List(db), "Id", "Notes", grant.Product);
            return(View(grant));
        }