void Update(ServiceMaterial serviceMaterial, ServiceMaterial result) { result.MaterialId = serviceMaterial.MaterialId; result.ServiceId = serviceMaterial.ServiceId; result.UserId = serviceMaterial.UserId; result.Id = serviceMaterial.Id; result.Quantity = serviceMaterial.Quantity; }
protected void UpdatServiceMaterials(ServiceMaterial serviceMaterial) { Publish(Messages.REQUEST_SAVE_SERVICE_MATERIAL, new ServiceMaterial() { Id = serviceMaterial.Id, ServiceId = serviceMaterial.ServiceId, MaterialId = serviceMaterial.MaterialId }); }
protected override void Update(ServiceMaterial serviceMaterial) { var existingMaterial = ServiceMaterials.FirstOrDefault(sm => sm.ServiceId == serviceMaterial.ServiceId && sm.MaterialId == serviceMaterial.MaterialId); existingMaterial.ServiceId = serviceMaterial.ServiceId; existingMaterial.MaterialId = serviceMaterial.MaterialId; existingMaterial.Quantity = serviceMaterial.Quantity; existingMaterial.UserId = serviceMaterial.UserId; }
Service GetService(ServiceMaterial serviceMaterial) { Service service = null; Subscribe(Messages.REQUEST_SERVICE_RESPONSE, payload => service = payload as Service); Publish(Messages.REQUEST_SERVICE, serviceMaterial.ServiceId); return service; }
protected abstract void SaveData(ServiceMaterial serviceMaterial);
protected override void SaveData(ServiceMaterial serviceMaterial) => _database.OnSave(serviceMaterial);
protected override ServiceMaterial Read(ServiceMaterial serviceMaterial) => ServiceMaterials.FirstOrDefault(sm => sm.ServiceId == serviceMaterial.ServiceId && sm.MaterialId == serviceMaterial.MaterialId);
public void get_material_from_service_material() { // Setup ClearSubscriptions(); var mock = new Mock(); var serviceMaterialsDatabase = mock.PrepareServiceMaterialsDependencies(); new Autonomy().Activate(); var profileId = new ProfileServer().GetProfile().Id; var material = new Material() { Name = SOME_TEXT, UserId = profileId }; Publish(Messages.REQUEST_SAVE_MATERIAL, material); var service = new Service() { Name = SOME_TEXT, UserId = profileId }; Publish(Messages.REQUEST_SAVE_SERVICE, service); var serviceMaterial = new ServiceMaterial() { MaterialId = material.Id, ServiceId = service.Id, Quantity = 1, UserId = profileId }; Publish(Messages.REQUEST_SAVE_SERVICE_MATERIAL, serviceMaterial); // Test Material materialResult = null; Subscribe(Messages.REQUEST_SERVICE_MATERIAL_RESPONSE, obj => materialResult = obj as Material); Publish(Messages.REQUEST_SERVICE_MATERIAL, material.Id); // Verify var expected = material == materialResult; Assert.IsTrue(expected); }
protected override void Add(ServiceMaterial serviceMaterial) => ServiceMaterials.Add(serviceMaterial);
protected override void Update(ServiceMaterial serviceMaterial) => _databaseConnection.Update(serviceMaterial);
protected override ServiceMaterial Read(ServiceMaterial serviceMaterial) => _databaseConnection.Table<ServiceMaterial>().FirstOrDefault( sm => sm.MaterialId == serviceMaterial.MaterialId && sm.ServiceId == serviceMaterial.ServiceId);
protected override void Add(ServiceMaterial serviceMaterial) => _databaseConnection.Insert(serviceMaterial);
protected abstract ServiceMaterial Read(ServiceMaterial serviceMaterial);
protected abstract void Update(ServiceMaterial serviceMaterial);
protected abstract void Add(ServiceMaterial serviceMaterial);
public void add_material_to_service() { // Setup new Mock().PrepareDatabases(); new Autonomy().Activate(); Mocks.SERVICE_1.Materials.Clear(); var viewModel = new ViewModel(); viewModel.Load.Execute(null); Publish(Messages.REQUEST_SAVE_SERVICE, Mocks.SERVICE_1); // Test Publish(Messages.REQUEST_SAVE_MATERIAL, Mocks.MATERIAL_2); var serviceMaterial = new ServiceMaterial() { MaterialId = Mocks.MATERIAL_2.Id, ServiceId = Mocks.SERVICE_1.Id }; Publish(Messages.REQUEST_SAVE_SERVICE_MATERIAL, serviceMaterial); // Verify var service = viewModel.Services.Single(); var expected = service.Materials.Contains(Mocks.MATERIAL_2); Assert.IsTrue(expected); }