public async void ModelUpdate() { // Arrange this.FleetDbContext.VehicleModels.AddRange( new VehicleModelEntity() { VehicleModelId = 1, Name = "PC138USLC-10", VehicleManufacturerId = 2, CompanyId = 1, DeletedInd = false }, new VehicleModelEntity() { VehicleModelId = 2, Name = "PC3000-6", VehicleManufacturerId = 2, CompanyId = 1, DeletedInd = false }); await this.SaveChangesAsync(this.FleetDbContext); VehicleManufacturerModelModel model = new VehicleManufacturerModelModel() { VehicleModelId = 2, Name = "PC8000-6" }; // Act AjaxModel <NTModel> ajaxModel = await this.Controller.ModelUpdate(model); // Assert VehicleModelEntity entity = this.FleetDbContext.VehicleModels.Where(e => e.VehicleModelId == 2).First(); Assert.Equal(entity.Name, "PC8000-6"); Assert.Equal(ajaxModel.Message, FleetMessages.VehicleModelSaveSuccess); }
public int AddToVehicleModel(PostVehicleArgs postveargs) { VehicleMakeEntity vehiclemakeentity = new VehicleMakeEntity(); vehiclemakeentity.Name = postveargs.make_Name; vehiclemakeentity.Abrv = postveargs.make_Abrv; VehicleModelEntity vehiclemodelentity = new VehicleModelEntity(); VehicleMakeEntity findvehiclemake = Context.VehicleMake.Find(postveargs.make_Id); if (findvehiclemake == null) { Context.VehicleMake.Add(vehiclemakeentity); Context.SaveChanges(); vehiclemodelentity.MakeId = vehiclemakeentity.Id; } else { vehiclemakeentity.Id = postveargs.make_Id; vehiclemodelentity.MakeId = postveargs.make_Id; } vehiclemodelentity.Id = postveargs.model_Id; vehiclemodelentity.Name = postveargs.model_Name; vehiclemodelentity.Abrv = postveargs.model_Abrv; Context.VehicleModel.Add(vehiclemodelentity); return(Context.SaveChanges()); }
async public Task <bool> CreateVehicleModel(string vehicleMakeName, int databseID, int makeID, int id, string modelName, string abbreviation) { VehicleModelEntity vm = new VehicleModelEntity(id, makeID, vehicleMakeName, modelName, abbreviation); vm.dataBaseId = databseID; var result = await database.SaveVehicleAsync(vm); return(result > 0); }
public VehicleModelEntity UpdateVehicleModel(VehicleModelEntity VehicleModel) { try { return(_vehicleModelEngine.UpdateVehicleModel(VehicleModel)); } catch (Exception e) { _exceptionHandlerLogic.LogExceptionAsync(e); throw e; } }
public async Task <int> Add(VehicleModel entity) { try { VehicleModelEntity vehicleModel = mapper.Map <VehicleModelEntity>(entity); return(await dataSource.GetConnection().InsertAsync(vehicleModel)); }catch (Exception ex) { throw new ServiceException(); } }
public int UpdateVehicleModel(VehicleModelArgs model_model) { VehicleModelEntity vehiclemodelentity = new VehicleModelEntity(); vehiclemodelentity.Id = model_model.Id; vehiclemodelentity.Name = model_model.Name; vehiclemodelentity.Abrv = model_model.Abrv; vehiclemodelentity.MakeId = model_model.MakeId; Context.VehicleModel.Update(vehiclemodelentity); return(Context.SaveChanges()); }
public VehicleModelEntity AddVehicleModel(VehicleModelEntity VehicleModel) { using (var context = DataAccess.GetDBContext) { var VehicleModelElement = Mapper.Map <VehicleModels>(VehicleModel); context.VehicleModels.Add(VehicleModelElement); context.SaveChanges(); return(context.VehicleModels .Where(v => v.VehicleModelId == VehicleModelElement.VehicleModelId) .ProjectTo <VehicleModelEntity>() .FirstOrDefault()); } }
public async Task <int> Delete(VehicleModel entity) { try { VehicleModelEntity vehicleModel = mapper.Map <VehicleModelEntity>(entity); return(await dataSource.GetConnection().Table <VehicleModelEntity>().DeleteAsync(x => x.Id == vehicleModel.Id && x.MakeId == vehicleModel.MakeId)); } catch (Exception ex) { throw new ServiceException(); } }
public async Task <VehicleModel> GetById(int id) { try { VehicleModelEntity vehicleModel = await dataSource.GetConnection().FindAsync <VehicleModelEntity>(x => x.Id == id); return(mapper.Map <VehicleModel>(vehicleModel)); } catch (Exception ex) { throw new ServiceException(); } }
public async void ModelAdd() { // Arrange VehicleManufacturerModelModel model = new VehicleManufacturerModelModel() { VehicleModelId = 0, Name = "PC8000-6" }; // Act AjaxModel <NTModel> ajaxModel = await this.Controller.ModelAdd(model); // Assert VehicleModelEntity entity = this.FleetDbContext.VehicleModels.Last(); Assert.Equal(entity.Name, "PC8000-6"); Assert.Equal(ajaxModel.Message, FleetMessages.VehicleModelSaveSuccess); }
public async Task <IVehicleModel> DeleteVehicleModelAsync(Guid id) { if (id != null) { VehicleModelEntity vehicleModelEntity = Context.VehicleModels.Find(id); if (vehicleModelEntity != null) { Context.VehicleModels.Remove(vehicleModelEntity); await Context.SaveChangesAsync(); var vehicleModel = Mapper.Map <VehicleModel>(vehicleModelEntity); return(vehicleModel); } return(null); } return(null); }
public VehicleModelEntity UpdateVehicleModel(VehicleModelEntity VehicleModel) { using (var context = DataAccess.GetDBContext) { var VehicleModelElement = context.VehicleModels .Where(m => m.VehicleModelId == VehicleModel.VehicleModelId) .FirstOrDefault(); if (VehicleModelElement == null) { return(null); } VehicleModelElement.Name = VehicleModel.Name; VehicleModelElement.ManufacturerId = VehicleModel.ManufacturerId; VehicleModelElement.VehicleTypeId = VehicleModel.VehicleTypeId; VehicleModelElement.ModifiedDate = DateTime.Now; context.SaveChanges(); return(context.VehicleModels .Where(v => v.VehicleModelId == VehicleModelElement.VehicleModelId) .ProjectTo <VehicleModelEntity>() .FirstOrDefault()); } }
public void InsertModelTest() { //arrange var vehiclemake = new VehicleMakeEntity(); var vehiclemodel = new VehicleModelEntity(); var vehicledto = new VehicleDto(); var testMakeRepository = new Mock <IMakeRepository>(); testMakeRepository.Setup(m => m.InsertAsync(vehiclemake)) .Returns(Task.CompletedTask); var testModelRepository = new Mock <IModelRepository>(); testModelRepository.Setup(m => m.InsertAsync(vehiclemodel)) .Returns(Task.CompletedTask); var testUnitOfWork = new Mock <IUnitOfWork>(); //var options = new DbContextOptionsBuilder<ProjectDbContext>().UseInMemoryDatabase(databaseName: "mono").Options; var context = new Mock <ProjectDbContext>(); context.Setup(m => m.Add(vehiclemake)); var testingClass = new VehicleService(testUnitOfWork.Object, testMakeRepository.Object, testModelRepository.Object); //act var insertMethod = testingClass.InsertModelAsync(vehiclemodel); //assert //testingClass.InsertModel().Should(). Assert.True(insertMethod.IsCompletedSuccessfully); }
public void Details(VehicleModelEntity entity) { context.VehicleModel.Find(entity); context.SaveChanges(); }
public void Update(VehicleModelEntity entity) { context.VehicleModel.Update(entity); context.SaveChanges(); }
public void Insert(VehicleModelEntity entity) { context.VehicleModel.Add(entity); context.SaveChanges(); }
public void Delete(VehicleModelEntity entity) { context.VehicleModel.Remove(entity); context.SaveChanges(); }
/// <summary> /// ADD VEHICLE MODEL /// </summary> /// <param name="vehicleModelEntity"></param> /// <returns></returns> public async Task AddVehicleModelAsync(VehicleModelEntity vehicleModelEntity) { await repository.Insert(vehicleModelEntity); }
private VehicleModel MapToVehicleModel(VehicleModelEntity vehicle) { return(App.Mapper.Map <VehicleModelEntity, VehicleModel>(vehicle)); }
public async Task <VehicleModelEntity> UpdateAsync(VehicleModelEntity updatedItem) { return(await repository.UpdateAsync(updatedItem)); }
public async Task <VehicleModelEntity> CreteAsync(VehicleModelEntity newItem) { return(await repository.CreteAsync(newItem)); }
/// <summary> /// DELETE VEHICLE MODEL /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task DeleteVehicleModelAsync(int id) { VehicleModelEntity vehicleModelEntity = await repository.GetById(id); await repository.Delete(vehicleModelEntity); }
public async Task UpdateVehicleModelAsync(VehicleModelEntity updateVehicleModel) { await repository.Update(updateVehicleModel); }