Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "LoaiNvId,LoaiNvName")] LoaiNv loaiNv)
 {
     if (ModelState.IsValid)
     {
         Models.LoaiNvModel.Instance.Update(loaiNv.LoaiNvId, loaiNv.LoaiNvName);
         return(RedirectToAction("Index"));
     }
     return(View(loaiNv));
 }
Exemplo n.º 2
0
        // GET: LoaiNvs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LoaiNv loaiNv = Models.LoaiNvModel.Instance.GetById(id.GetValueOrDefault(0));

            if (loaiNv == null)
            {
                return(HttpNotFound());
            }
            return(View(loaiNv));
        }
Exemplo n.º 3
0
        public string Insert(string name)
        {
            var message = "";

            name = name.Trim();
            try {
                LoaiNv newItem = new LoaiNv();
                newItem.LoaiNvName = name;
                _db.LoaiNvs.Add(newItem);
                _db.SaveChanges();
            }
            catch (Exception e) {
                Console.WriteLine(e);
                message = e.Message;
            }
            return(message);
        }