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; }
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; }
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); }