Example #1
0
        public ActionResult Create(KaryawanFormStub model)
        {
            //bool isNameExist = RepoContractor.Find().Where(p => p.name == model.Name).Count() > 0;

            if (ModelState.IsValid)
            {
                tbKaryawan dbItem = new tbKaryawan();
                dbItem = model.GetDbObject(dbItem);

                try
                {
                    RepoKaryawan.Save(dbItem);
                }
                catch (Exception e)
                {
                    return(View("Form", model));
                }

                //message
                string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString();
                this.SetMessage(model.NamaKaryawan, template);

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