Exemplo n.º 1
0
        public int CustomAddCarClass(CarClassContract carClass)
        {
            try
            {
                //Re-Map Object to Entity Object
                var myEntityObj = CarClassContractMapper.Map<CarClassContract, CarClass>(carClass);
                if (myEntityObj == null)
                { return -2; }

                var checkDuplicate = _repository.GetAll(m => m.Name.ToLower().Replace(" ", "") == carClass.Name.ToLower().Replace(" ", ""));
                if (checkDuplicate.Any())
                {
                    return -1;
                }

                var processedCarClass = _repository.Add(myEntityObj);
                _uoWork.SaveChanges();
                return processedCarClass.CarClassId;
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return 0;
            }
        }
Exemplo n.º 2
0
 public int CustomAddCarClass(CarClassContract carClass)
 {
     try
     {
         return _carClassRepository.CustomAddCarClass(carClass);
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return 0;
     }
 }
Exemplo n.º 3
0
 public int AddCarClass(CarClassContract carClass)
 {
     try
     {
         //Re-Map Object to Entity Object
         var myEntityObj = CarClassContractMapper.Map<CarClassContract, CarClass>(carClass);
         if(myEntityObj == null)
         {return -2;}
         var processedCarClass =  _repository.Add(myEntityObj);
         _uoWork.SaveChanges();
         return  processedCarClass.CarClassId;
     }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return 0;
     }
 }
Exemplo n.º 4
0
 public JsonResult AddNewCarClass(CarClassContract model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
         }
         var retVal = ServiceProvider.Instance().GetCarClassServices().CustomAddCarClass(model);
         if (retVal < 1)
         {
             return Json(new { IsSuccess = false, Message = "Invalid input / CarClass Already Exist" });
         }
         return Json(new { IsSuccess = true, Message = "" });
     }
     catch
     {
         return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
     }
 }
Exemplo n.º 5
0
 public ActionResult AddNewCarClass(CarClassContract model)
 {
     try
     {
         var carClass = ServiceProvider.Instance().GetCarClassServices().GetCarClasses() ?? new List<CarClassContract>();
         //model.Countrys = new SelectList(countryList, "CountryId", "Name", model.CountryId);
         if (!ModelState.IsValid)
         {
             return View(model);
         }
         var retVal = ServiceProvider.Instance().GetCarClassServices().CustomAddCarClass(model);
         if (retVal < 1)
         {
             ModelState.AddModelError("message", "Unable to add CarClass");
             return View(model);
         }
         return RedirectToAction("CarClassList");
     }
     catch
     {
         ModelState.AddModelError("message", "Process Error Occurred!");
         return View(model);
     }
 }
Exemplo n.º 6
0
 //
 // GET: /CarClass/Details/5
 public PartialViewResult AddNewCarClass()
 {
     var carClass = new CarClassContract();
     return PartialView("AddNewCarClass", carClass);
 }
Exemplo n.º 7
0
 public JsonResult _EditCarClassInfo(CarClassContract model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
         }
         var retVal = ServiceProvider.Instance().GetCarClassServices().UpdateCarClass(model);
         if (!retVal)
         {
             return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
         }
         return Json(new { IsSuccess = true, Message = "" });
     }
     catch
     {
         return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
     }
 }
Exemplo n.º 8
0
 public ActionResult EditCarClassInfo(CarClassContract model)
 {
     try
     {
         var retVal = ServiceProvider.Instance().GetCarClassServices().UpdateCarClass(model);
         if (!retVal)
         {
             return PartialView("EditCarClass", model);
         }
         return RedirectToAction("CarClassList");
     }
     catch
     {
         return PartialView("EditCarClass", model);
     }
 }
Exemplo n.º 9
0
        public JsonResult _EditCarClassInfo(CarClassContract model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
                }
                var retVal = ServiceProvider.Instance().GetCarClassServices().UpdateCarClass(model);
                if (!retVal)
                {
                    return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
                }

                var carClass = ServiceProvider.Instance().GetCarClassServices().GetCarClasses() ?? new List<CarClassContract>();
                return Json(new { IsSuccess = true, CarClassItems = carClass }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json(new { IsSuccess = false, Message = "Invalid inputs / validation error" });
            }
        }
Exemplo n.º 10
0
 public bool UpdateCarClass(CarClassContract carClass)
 {
     try
     {
         return _carClassRepository.UpdateCarClass(carClass);
         }
     catch (Exception ex)
     {
         ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return false;
     }
 }