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

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

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

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

                return RedirectToAction("Index");
            }
            else
            {
                return View("Form", model);
            }
        }
Example #2
0
        public ActionResult Create()
        {
            ContractorFormStub formStub = new ContractorFormStub();

            return View("Form", formStub);
        }
Example #3
0
 public ActionResult Edit(int id)
 {
     contractor contractor = RepoContractor.FindByPk(id);
     ContractorFormStub formStub = new ContractorFormStub(contractor);
     return View("Form", formStub);
 }