示例#1
0
        public ActionResult Create([Bind(Include = "Id, Debt, Employee, IsActive, Notes")] Warrant warrant)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    WarrantServices.Insert(CurrentUser.Id, warrant, 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.DebtList     = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber");
            ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName");
            return(View(warrant));
        }
示例#2
0
        public ActionResult Create()
        {
            Db db = new Db(DbServices.ConnectionString);

            ViewBag.DebtList     = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber");
            ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName");
            return(View());
        }
示例#3
0
        // GET: Warrant/Edit/5
        public ActionResult Edit(Nullable <int> id)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Warrant warrant = WarrantServices.Get(id.Value, db);

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

            ViewBag.DebtList     = new SelectList(DebtServices.List(db), "Id", "ReferenceNumber", warrant.Debt);
            ViewBag.EmployeeList = new SelectList(EmployeeServices.List(db), "Id", "FirstName", warrant.Employee);
            return(View(warrant));
        }