Exemplo n.º 1
0
        public ActionResult Create(MaterialListItemViewModel materialListItem)
        {
            if (ModelState.IsValid)
            {
                tMaterial tmaterial = new tMaterial();
                tmaterial.Name = materialListItem.Name;
                tmaterial.Description = materialListItem.Description;

                _db.tMaterial.Add(tmaterial);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(materialListItem);
        }
Exemplo n.º 2
0
        public ActionResult Edit(MaterialListItemViewModel materialListItem)
        {
            if (ModelState.IsValid)
            {
                tMaterial tmaterial = _db.tMaterial.Find(materialListItem.MaterialID);

                tmaterial.Name = materialListItem.Name;
                tmaterial.Description = materialListItem.Description;

                _db.Entry(tmaterial).State = EntityState.Modified;
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(materialListItem);
        }
Exemplo n.º 3
0
        private List<MaterialListItemViewModel> GetMaterialList()
        {
            List<MaterialListItemViewModel> materialList = new List<MaterialListItemViewModel>();

            foreach (var dbItem in _db.tMaterial.ToList())
            {
                MaterialListItemViewModel listItem = new MaterialListItemViewModel();

                listItem.MaterialID = dbItem.MaterialID;
                listItem.Name = dbItem.Name;
                listItem.Description = dbItem.Description;

                materialList.Add(listItem);
            }

            return materialList;
        }
Exemplo n.º 4
0
        public ActionResult GetMaterialListItem(int id)
        {
            tMaterial tmaterial = _db.tMaterial.Find(id);

            MaterialListItemViewModel materialItem = new MaterialListItemViewModel();

            if (tmaterial == null)
            {
                return HttpNotFound();
            }
            else
            {
                materialItem.MaterialID = tmaterial.MaterialID;
                materialItem.Name = tmaterial.Name;
                materialItem.Description = tmaterial.Description;
            }

            return View(materialItem);
        }
Exemplo n.º 5
0
 public ActionResult Edit(MaterialListItemViewModel materialListItem)
 {
     return _materialViewModel.Edit(materialListItem);
 }
Exemplo n.º 6
0
 public ActionResult Create(MaterialListItemViewModel materialListItem)
 {
     return _materialViewModel.Create(materialListItem);
 }