Ejemplo n.º 1
0
        public ActionResult Edit(DataTruck model)
        {
            if (ModelState.IsValid)
            {
                if (RepoDataTruck.IsExist(model.VehicleNo, model.Id))
                {
                    ModelState.AddModelError("VehicleNo", "Vehicle No sudah terdaftar.");
                    return(View("Form", model));
                }
                Context.DataTruck dbitem = RepoDataTruck.FindByPK(model.Id);
                model.SetDb(dbitem);
                RepoDataTruck.save(dbitem, UserPrincipal.id);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }
Ejemplo n.º 2
0
        public ActionResult Add(DataTruck model)
        {
            if (ModelState.IsValid)
            {
                if (RepoDataTruck.IsExist(model.VehicleNo))
                {
                    ModelState.AddModelError("VehicleNo", "Vehicle No sudah terdaftar.");
                    return(View("Form", model));
                }
                Context.DataTruck dbitem = new Context.DataTruck();
                model.SetDb(dbitem);
                //generate code
                dbitem.urutan  = RepoDataTruck.getUrutan() + 1;
                dbitem.NoTruck = RepoDataTruck.generateCode(dbitem.urutan);

                RepoDataTruck.save(dbitem, UserPrincipal.id);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }