コード例 #1
0
        public ActionResult Index(MechanicViewModel mechanic)
        {
            // Exception Handling
            try
            {
                if (ModelState.IsValid)
                {
                    string add = _mechanicManager.CreateMechanic(mechanic);
                    Log.Info("Mechanic created Successffuly");
                    return(RedirectToAction("Index"));
                }
            }
            // Catch the Exception
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                ModelState.AddModelError("", "Error in mechanic created");
            }
            var mechanics = new MechanicViewModel()
            {
                mechaniclist = _mechanicManager.GetAllMechanic()
            };

            return(View(mechanics));
        }
コード例 #2
0
 public ActionResult Create(MechanicViewModel mechanic)
 {
     if (ModelState.IsValid)
     {
         string add = _mechanicManager.CreateMechanic(mechanic);
         return(RedirectToAction("Index"));
     }
     ViewBag.DeptId = new SelectList(_departmentManager.GetAllDepartment(), "DeptId", "Department1");
     return(View(mechanic));
 }