예제 #1
0
        public ActionResult Edit(string id)
        {
            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var item = _unitOfWork.VehicleEngineType.GetByID(Convert.ToInt32(id));
                VehicleEngineTypeViewModel vehicleEngineTypeViewModel = new VehicleEngineTypeViewModel();
                vehicleEngineTypeViewModel.EngineTypeName      = item.EngineTypeName;
                vehicleEngineTypeViewModel.VehicleEngineTypeId = item.VehicleEngineTypeId;

                if (vehicleEngineTypeViewModel != null)
                {
                    return(PartialView("_EditvehicleEngineType", vehicleEngineTypeViewModel));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public ActionResult Details(string id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }


                VehicleEngineType          vehicleEngineType          = _unitOfWork.VehicleEngineType.GetByID(Convert.ToInt32(id));
                VehicleEngineTypeViewModel vehicleEngineTypeViewModel = new VehicleEngineTypeViewModel();

                vehicleEngineTypeViewModel.EngineTypeName = vehicleEngineType.EngineTypeName;

                if (vehicleEngineTypeViewModel != null)
                {
                    return(PartialView("_DetailsvehicleEngineType", vehicleEngineTypeViewModel));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
 public ActionResult AddNew(VehicleEngineTypeViewModel vehicleEngineTypeViewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             VehicleEngineTypeRepository vehicleEngineTypeRepository = new VehicleEngineTypeRepository(new AutoSolutionContext());
             bool IsExist = vehicleEngineTypeRepository.isExist(vehicleEngineTypeViewModel.EngineTypeName);
             if (!IsExist)
             {
                 VehicleEngineType vehicleEngineType = new VehicleEngineType();
                 vehicleEngineType.EngineTypeName = vehicleEngineTypeViewModel.EngineTypeName;
                 _unitOfWork.VehicleEngineType.Add(vehicleEngineType);
                 _unitOfWork.Complete();
                 _unitOfWork.Dispose();
                 return(RedirectToAction("GetVehicleEngineType"));
             }
             else
             {
                 return(RedirectToAction("GetVehicleEngineType"));
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(View());
 }
예제 #4
0
        public ActionResult Edit(VehicleEngineTypeViewModel vehicleEngineTypeViewModel)
        {
            VehicleEngineType vehicleEnginetype = new VehicleEngineType();

            vehicleEnginetype = _unitOfWork.VehicleEngineType.GetByID(vehicleEngineTypeViewModel.VehicleEngineTypeId);
            vehicleEnginetype.EngineTypeName = vehicleEngineTypeViewModel.EngineTypeName;

            vehicleEnginetype.VehicleEngineTypeId = vehicleEngineTypeViewModel.VehicleEngineTypeId;
            _unitOfWork.VehicleEngineType.Update(vehicleEnginetype);
            _unitOfWork.Complete();
            _unitOfWork.Dispose();
            return(RedirectToAction("GetVehicleEngineType"));
        }
예제 #5
0
 public ActionResult GetVehicleEngineType(int?pageNo)
 {
     try
     {
         var Items = _unitOfWork.VehicleEngineType.GetAll();
         VehicleEngineTypeViewModel vehicleEngineTypeViewModel = new VehicleEngineTypeViewModel();
         int   TotalCount = _unitOfWork.VehicleEngineType.Count();
         Pager pager      = new Pager(TotalCount, pageNo, 10);
         vehicleEngineTypeViewModel.VehicleEngineTypeList = Items;
         vehicleEngineTypeViewModel.Pager = pager;
         return(PartialView("_GetVehicleEngineType", vehicleEngineTypeViewModel));
     }
     catch (Exception)
     {
         return(View("Error"));
     }
 }