public async Task <bool> Update(VehicleModelServ entity) { bool provjera = false; if (entity != null) { VehicleModelRepo vehicleModelRepo = mapper.Map <VehicleModelRepo>(entity); provjera = await unitOfWork.VehicleModelRepository.Update(vehicleModelRepo); if (provjera) { unitOfWork.Complete(); } } return(provjera); }
public async Task <bool> Add(VehicleModelServ entity) { bool provjera = false; if (entity != null || entity.MakeId != 0) { VehicleModelRepo vehicleModel = mapper.Map <VehicleModelRepo>(entity); provjera = await unitOfWork.VehicleModelRepository.Add(vehicleModel); if (provjera) { unitOfWork.Complete(); } } return(provjera); }
public async Task <bool> Update(VehicleModelRepo entity) { bool provjera = true; if (entity != null) { VehicleModel vehicleModel = mapper.Map <VehicleModel>(entity); var updatedVehicleModel = await vehicleModelSet.FindAsync(vehicleModel.Id); if (updatedVehicleModel != null) { if (IsNameNotExist(updatedVehicleModel.Id, vehicleModel.Name)) { updatedVehicleModel.Name = vehicleModel.Name; } else { provjera = false; } if (IsAbrvNotExist(updatedVehicleModel.Id, vehicleModel.Abrv)) { updatedVehicleModel.Abrv = vehicleModel.Abrv; } else { provjera = false; } if (IsMakeExist(vehicleModel.MakeId)) { if (vehicleModel.MakeId != 0) { updatedVehicleModel.MakeId = vehicleModel.MakeId; } } else { provjera = false; } } } else { provjera = false; } return(provjera); }
public async Task <bool> Delete(VehicleModelRepo entity) { bool provjera = false; if (entity != null) { VehicleModel vehicleModel = mapper.Map <VehicleModel>(entity); VehicleModel model = await vehicleModelSet.FindAsync(vehicleModel.Id); if (model != null) { vehicleModelSet.Remove(model); provjera = true; } } return(provjera); }
public async Task <bool> Add(VehicleModelRepo entity) { bool provjera = false; if (entity != null) { VehicleModel vehicleModel = mapper.Map <VehicleModel>(entity); if (IsNotExist(vehicleModel) && IsMakeExist(vehicleModel.MakeId)) { VehicleModel model = vehicleModelSet.Add(vehicleModel); if (model != null) { provjera = true; } } } return(provjera); }
public async Task <VehicleModelServ> GetById(int id) { VehicleModelRepo vehicleModelRepo = await unitOfWork.VehicleModelRepository.GetById(id); return(mapper.Map <VehicleModelServ>(vehicleModelRepo)); }