Esempio n. 1
0
        private void UpdateDocument(object obj)
        {
            if (UpsertedDocument != new Document())
            {
                UpsertedDocument.Violations = ChosenViolations.ToList();
                if (documentsService.UpdateDocument(UpsertedDocument))
                {
                    var existingRecord = Documents.FirstOrDefault(d => d.Id == UpsertedDocument.Id);
                    PropertyCopy.Copy(UpsertedDocument, existingRecord);
                    //Documents.Remove(existingRecord);
                    //Documents.Add(UpsertedDocument);

                    Messenger.ShowMessage("Успешна редакция", MessageType.Success);
                }
                else
                {
                    Messenger.ShowMessage("Грешка при редакция на документа!", MessageType.Error);
                }

                ResetDocumentOnUpsert();
            }
            else
            {
                Messenger.ShowMessage("Грешка при редакция на документа!", MessageType.Error);
            }
        }
Esempio n. 2
0
        private void InsertDocument(object obj)
        {
            if (UpsertedDocument != new Document())
            {
                UpsertedDocument.Violations = ChosenViolations.ToList();

                // Generate regNumber
                if (string.IsNullOrEmpty(UpsertedDocument.RegNumber))
                {
                    if (Documents.Any())
                    {
                        UpsertedDocument.RegNumber =
                            string.Format("{0} - {1}", Documents.FirstOrDefault(d => d.Id == Documents.Select(doc => doc.Id).Max()).Id, DateTime.Today.Date);
                    }
                }

                UpsertedDocument.Id = documentsService.InsertDocument(UpsertedDocument);
                if (UpsertedDocument.Id > 0)
                {
                    Documents.Add(UpsertedDocument);
                    Messenger.ShowMessage("Успешен запис", MessageType.Success);
                }
                else
                {
                    Messenger.ShowMessage("Неуспешен запис!", MessageType.Error);
                }

                ResetDocumentOnUpsert();
            }
            else
            {
                Messenger.ShowMessage("Липсва документ!", MessageType.Error);
            }
        }
Esempio n. 3
0
        private void RemoveViolationFromDocument(object obj)
        {
            if (ChosenViolations == null)
            {
                ChosenViolations = new ObservableCollection <Violation>();
            }

            ChosenViolations.Remove(SelectedViolation);
        }
Esempio n. 4
0
        private void AddViolationToDocument(object obj)
        {
            if (ChosenViolations == null)
            {
                ChosenViolations = new ObservableCollection <Violation>();
            }

            if (!ChosenViolations.Contains(ViolationToAdd))
            {
                ChosenViolations.Add(ViolationToAdd);
            }
        }