Esempio n. 1
0
 //
 // GET: /Contractor/JList
 public JsonResult JList(string term = "")
 {
     List<ListItemModel> model = null;
     using (ContractorContext context = new ContractorContext())
     {
         model = context.GetList(term);
     }
     return Json(model, JsonRequestBehavior.AllowGet);
 }
Esempio n. 2
0
 //
 // GET: /Contractor/
 public ActionResult Index()
 {
     List<ContractorModel> model = null;
     using (ContractorContext context = new ContractorContext())
     {
         model = context.GetContractors();
     }
     return View(model);
 }
Esempio n. 3
0
        //
        // GET: /Contractor/Edit/Id
        public ActionResult Edit(int id = 0)
        {
            ContractorModel model = null;
            using (ContractorContext context = new ContractorContext())
            {
                model = context.GetContractor(id);
            }

            if (model == null)
            { return RedirectToAction("Index"); }
            // Физическо лице
            else if (model.ContractorTypeId == 1)
            { return View("EditPerson", model); }
            // // Юридическо лице
            else if (model.ContractorTypeId == 2)
            { return View("EditCompany", model); }
            else
            { return RedirectToAction("Index"); }
        }
Esempio n. 4
0
 public ActionResult Edit(ContractorModel model)
 {
     if (!ModelState.IsValid)
     {
         // Физическо лице
         if (model.ContractorTypeId == 1)
         { return View("EditPerson", model); }
         // // Юридическо лице
         else if (model.ContractorTypeId == 2)
         { return View("EditCompany", model); }
         else
         { return RedirectToAction("Index"); }
     }
     else
     {
         using (ContractorContext context = new ContractorContext())
         {
             context.Edit(model);
         }
         return RedirectToAction("Index");
     }
 }
Esempio n. 5
0
 public ActionResult NewCompany(ContractorModel model)
 {
     if (!ModelState.IsValid)
     {
         return View("EditCompany", model);
     }
     else
     {
         using (ContractorContext context = new ContractorContext())
         {
             model.ContractorTypeId = 2; // Юридическо лице
             context.Add(model);
         }
         return RedirectToAction("Index");
     }
 }