コード例 #1
0
ファイル: CarTypeService.cs プロジェクト: codedive/MyDemo1
 public CarTypeModel SaveCarType(CarTypeModel model)
 {
     //unitOfWork.StartTransaction();
     CarTypeRepository repo = new CarTypeRepository(unitOfWork);
     CarType carType = new CarType();
     AutoMapper.Mapper.Map(model, carType);
     repo.Insert(carType);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(carType, model);
     return model;
 }
コード例 #2
0
ファイル: CarTypeService.cs プロジェクト: codedive/MyDemo1
 public CarTypeModel GetCarTypeById(int carTypeId)
 {
     //unitOfWork.StartTransaction();
     CarTypeRepository repo = new CarTypeRepository(unitOfWork);
     CarTypeModel carTypeModel = new CarTypeModel();
     CarType carType = new CarType();
     AutoMapper.Mapper.Map(carTypeModel, carType);
     carType = repo.GetAll().Where(x => x.CarTypeId == carTypeId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(carType, carTypeModel);
     return carTypeModel;
 }
コード例 #3
0
        public IHttpActionResult UpdateCarType(CarTypeBindingModel model)
        {

            CarTypeModel carTypeModel = new CarTypeModel();
            AutoMapper.Mapper.Map(model, carTypeModel);
            try
            {

                carTypeModel = carTypeService.UpadteCarType(carTypeModel);
                AutoMapper.Mapper.Map(carTypeModel, model);

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return BadRequest(ex.Message);
            }
            return Json(model);
        }