public ShipmentDocumentViewModel GetDataToValidate() { ShipmentDocumentViewModel TestData = new ShipmentDocumentViewModel() { Buyer = new BuyerIntegrationViewModel() { Id = 1 }, DeliveryDate = DateTimeOffset.Now, DeliveryCode = "DeliveryCode", ProductIdentity = "ProductIdentity", ShipmentNumber = "ShipmentNumber", Details = new List <ShipmentDocumentDetailViewModel>() { new ShipmentDocumentDetailViewModel() { Items = new List <ShipmentDocumentItemViewModel>() { new ShipmentDocumentItemViewModel() { PackingReceiptItems = new List <ShipmentDocumentPackingReceiptItemViewModel>() { new ShipmentDocumentPackingReceiptItemViewModel() } } } } } }; return(TestData); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new ShipmentDocumentSQLiteRepository().SetStatusDeleted(CurrentShipmentDocumentDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentShipmentDocumentForm = new ShipmentDocumentViewModel(); CurrentShipmentDocumentForm.Identifier = Guid.NewGuid(); CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added; CurrentShipmentDocumentDG = null; ShipmentCreatedUpdated(); Thread displayThread = new Thread(() => DisplayShipmentDocumentData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public ShipmentDocumentResponse Create(ShipmentDocumentViewModel ShipmentDocument) { ShipmentDocumentResponse response = new ShipmentDocumentResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, ShipmentDocument); insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
public void Should_Success_Validate_DeliveryDate() { var vm = new ShipmentDocumentViewModel() { DeliveryDate = DateTimeOffset.UtcNow.AddDays(1), }; Assert.True(vm.Validate(null).Count() > 0); }
private void btnEditDocument_Click(object sender, RoutedEventArgs e) { CurrentShipmentDocumentForm = new ShipmentDocumentViewModel(); CurrentShipmentDocumentForm.Identifier = CurrentShipmentDocumentDG.Identifier; CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Edited; CurrentShipmentDocumentForm.IsSynced = CurrentShipmentDocumentDG.IsSynced; CurrentShipmentDocumentForm.Name = CurrentShipmentDocumentDG.Name; CurrentShipmentDocumentForm.CreateDate = CurrentShipmentDocumentDG.CreateDate; CurrentShipmentDocumentForm.Path = CurrentShipmentDocumentDG.Path; CurrentShipmentDocumentForm.UpdatedAt = CurrentShipmentDocumentDG.UpdatedAt; }
public void Mapping_With_AutoMapper_Profiles() { var configuration = new MapperConfiguration(cfg => { cfg.AddProfile <ShipmentDocumentProfile>(); }); var mapper = configuration.CreateMapper(); ShipmentDocumentViewModel vm = new ShipmentDocumentViewModel { Id = 1 }; ShipmentDocumentModel model = mapper.Map <ShipmentDocumentModel>(vm); Assert.Equal(vm.Id, model.Id); }
public void Should_Success_Instantiate() { ShipmentDocumentViewModel viewModel = new ShipmentDocumentViewModel() { UId = "UId", Code = "Code", DeliveryReference = "DeliveryReference", IsVoid = true, Storage = new StorageIntegrationViewModel() }; Assert.Equal("UId", viewModel.UId); Assert.Equal("Code", viewModel.Code); Assert.Equal("DeliveryReference", viewModel.DeliveryReference); Assert.True(viewModel.IsVoid); Assert.NotNull(viewModel.Storage); }
public static ShipmentDocumentViewModel ConvertToShipmentDocumentViewModelLite(this ShipmentDocument shipmentDocument) { ShipmentDocumentViewModel ShipmentDocumentViewModel = new ShipmentDocumentViewModel() { Id = shipmentDocument.Id, Identifier = shipmentDocument.Identifier, Name = shipmentDocument.Name, CreateDate = shipmentDocument.CreateDate, Path = shipmentDocument.Path, ItemStatus = shipmentDocument.ItemStatus, IsActive = shipmentDocument.Active, UpdatedAt = shipmentDocument.UpdatedAt, CreatedAt = shipmentDocument.CreatedAt }; return(ShipmentDocumentViewModel); }
private static ShipmentDocumentViewModel Read(SqliteDataReader query) { int counter = 0; ShipmentDocumentViewModel dbEntry = new ShipmentDocumentViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.Shipment = SQLiteHelper.GetShipment(query, ref counter); dbEntry.Name = SQLiteHelper.GetString(query, ref counter); dbEntry.CreateDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.Path = SQLiteHelper.GetString(query, ref counter); dbEntry.ItemStatus = SQLiteHelper.GetInt(query, ref counter); dbEntry.IsSynced = SQLiteHelper.GetBoolean(query, ref counter); dbEntry.UpdatedAt = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.CreatedBy = SQLiteHelper.GetCreatedBy(query, ref counter); dbEntry.Company = SQLiteHelper.GetCompany(query, ref counter); return(dbEntry); }
public ShipmentDocumentListResponse GetShipmentDocumentsByShipment(int companyId, Guid ShipmentIdentifier) { ShipmentDocumentListResponse response = new ShipmentDocumentListResponse(); List <ShipmentDocumentViewModel> ShipmentDocuments = new List <ShipmentDocumentViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM ShipmentDocuments " + "WHERE ShipmentIdentifier = @ShipmentIdentifier " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC;", db); selectCommand.Parameters.AddWithValue("@ShipmentIdentifier", ShipmentIdentifier); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { ShipmentDocumentViewModel dbEntry = Read(query); ShipmentDocuments.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.ShipmentDocuments = new List <ShipmentDocumentViewModel>(); return(response); } db.Close(); } response.Success = true; response.ShipmentDocuments = ShipmentDocuments; return(response); }
private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, ShipmentDocumentViewModel ShipmentDocument) { insertCommand.Parameters.AddWithValue("@ServerId", ShipmentDocument.Id); insertCommand.Parameters.AddWithValue("@Identifier", ShipmentDocument.Identifier); insertCommand.Parameters.AddWithValue("@ShipmentId", ((object)ShipmentDocument.Shipment.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ShipmentIdentifier", ((object)ShipmentDocument.Shipment.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ShipmentCode", ((object)ShipmentDocument.Shipment.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Name", ShipmentDocument.Name); insertCommand.Parameters.AddWithValue("@CreateDate", ((object)ShipmentDocument.CreateDate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Path", ((object)ShipmentDocument.Path) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)ShipmentDocument.ItemStatus) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@IsSynced", ShipmentDocument.IsSynced); insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)ShipmentDocument.UpdatedAt) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id); insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName); insertCommand.Parameters.AddWithValue("@CompanyId", MainWindow.CurrentCompany.Id); insertCommand.Parameters.AddWithValue("@CompanyName", MainWindow.CurrentCompany.CompanyName); return(insertCommand); }
public Shipment_Document_AddEdit(ShipmentViewModel Shipment) { ShipmentService = DependencyResolver.Kernel.Get <IShipmentService>(); ShipmentDocumentService = DependencyResolver.Kernel.Get <IShipmentDocumentService>(); InitializeComponent(); this.DataContext = this; CurrentShipment = Shipment; CurrentShipmentDocumentForm = new ShipmentDocumentViewModel(); CurrentShipmentDocumentForm.Identifier = Guid.NewGuid(); CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added; Thread displayThread = new Thread(() => DisplayShipmentDocumentData()); displayThread.IsBackground = true; displayThread.Start(); btnAddDocument.Focus(); }
public ShipmentDocumentResponse GetShipmentDocument(Guid identifier) { ShipmentDocumentResponse response = new ShipmentDocumentResponse(); ShipmentDocumentViewModel ShipmentDocument = new ShipmentDocumentViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM ShipmentDocuments " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { ShipmentDocumentViewModel dbEntry = Read(query); ShipmentDocument = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.ShipmentDocument = new ShipmentDocumentViewModel(); return(response); } db.Close(); } response.Success = true; response.ShipmentDocument = ShipmentDocument; return(response); }
public static ShipmentDocument ConvertToShipmentDocument(this ShipmentDocumentViewModel shipmentDocumentViewModel) { ShipmentDocument ShipmentDocument = new ShipmentDocument() { Id = shipmentDocumentViewModel.Id, Identifier = shipmentDocumentViewModel.Identifier, ShipmentId = shipmentDocumentViewModel.Shipment?.Id ?? null, Name = shipmentDocumentViewModel.Name, CreateDate = shipmentDocumentViewModel.CreateDate, Path = shipmentDocumentViewModel.Path, ItemStatus = shipmentDocumentViewModel.ItemStatus, Active = shipmentDocumentViewModel.IsActive, CreatedById = shipmentDocumentViewModel.CreatedBy?.Id ?? null, CompanyId = shipmentDocumentViewModel.Company?.Id ?? null, CreatedAt = shipmentDocumentViewModel.CreatedAt, UpdatedAt = shipmentDocumentViewModel.UpdatedAt }; return(ShipmentDocument); }
private void btnCancelDocument_Click(object sender, RoutedEventArgs e) { CurrentShipmentDocumentForm = new ShipmentDocumentViewModel(); CurrentShipmentDocumentForm.Identifier = Guid.NewGuid(); CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added; }
public void Should_Success_Validate_All_Null_Data() { var vm = new ShipmentDocumentViewModel(); Assert.True(vm.Validate(null).Count() > 0); }
private void btnAddDocument_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentShipmentDocumentForm.Name == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentShipmentDocumentForm.Shipment = CurrentShipment; CurrentShipmentDocumentForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentShipmentDocumentForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new ShipmentDocumentSQLiteRepository().Delete(CurrentShipmentDocumentForm.Identifier); var response = new ShipmentDocumentSQLiteRepository().Create(CurrentShipmentDocumentForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentShipmentDocumentForm = new ShipmentDocumentViewModel(); CurrentShipmentDocumentForm.Identifier = Guid.NewGuid(); CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added; CurrentShipmentDocumentForm.IsSynced = false; return; } CurrentShipmentDocumentForm = new ShipmentDocumentViewModel(); CurrentShipmentDocumentForm.Identifier = Guid.NewGuid(); CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added; CurrentShipmentDocumentForm.IsSynced = false; ShipmentCreatedUpdated(); DisplayShipmentDocumentData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtDocumentName.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }