Example #1
0
        private void AddNewLogBook()
        {
            using (dbContext db = new dbContext())
            {
                try
                {
                    var lb = new LogBook();
                    lb.Employeer = db.Employee.Find(this.Employeer.EmployeeId);
                    lb.Information = this.Information;
                    lb.ContactDate = ContactDate;
                    lb.Customer = db.Customer.Find(this.Customer.CustomerId);
                    lb.CustomerContactType = db.CustomerContactType.Find(this.CustomerContactType.CustomerContactTypeId);
                    db.LogBook.Add(lb);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {

                    Messenger.Default.Send(new NotificationMessage(ex.ToString()));
                }

            }
            Messenger.Default.Send(new NotificationMessage("CloseWindowLogBookItem"));
        }
Example #2
0
        private void AddLogBookItem()
        {
            var lbvm = new LogBookViewModel(SelectedCustomer.CustomerId);
            var lbv = new LogBookView();
            Messenger.Default.Register<MessangerLogBook>(this, (message) =>
            {
                switch (message.id)
                {
                    case 1:
                        using (dbContext db = new dbContext())
                        {
                            LogBook x = new LogBook();
                            x.Customer = db.Customer.Find(message.CustomerId);
                            x.CustomerContactType = db.CustomerContactType.Find(message.CustomerContactTypeId);
                            x.Information = message.Information;
                            x.Employeer = db.Employee.Find(message.EmployeerId);
                            x.ContactDate = message.ContactDate;
                            db.LogBook.Add(x);
                            db.SaveChanges();
                            //RaisePropertyChanged("SelectedCustomer");
                        }
                        break;
                }
            });
            lbv.DataContext = lbvm;
            lbv.ShowDialog();
            SearchCustomers();

        }
Example #3
0
 private void AddNewLogBook()
 {
     var lb = new LogBook();
     lb.Employeer = this.employeer;
     lb.Information = " ";
     lb.ContactDate = DateTime.Now;
     this.LogBookList.Add(lb);
     this.SelectedLogBook = lb;
 }