Exemplo n.º 1
0
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         con.Buildings.Add(Building);
         con.SaveChanges();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         con.Peoples.Add(Person);
         con.SaveChanges();
     }
 }
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         con.Specializations.Add(Specialization);
         con.SaveChanges();
     }
 }
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var specialization = con.Specializations.Find(Specialization.SpecializationID);
                specialization.Name = Specialization.Name;

                con.Entry(specialization).State = EntityState.Modified;
                con.SaveChanges();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var rent = con.Rents.Find(SelectedRent.PaymentID);
         rent.Ownership = null;
         con.Rents.Remove(rent);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var salary = con.Salaries.Find(SelectedSalary.PaymentID);
         salary.Menager = null;
         salary.Employee = null;
         con.Salaries.Remove(salary);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var expense = con.Expenses.Find(SelectedExpense.PaymentID);
         expense.ExpenseTarget = null;
         expense.Menager = null;
         con.Expenses.Remove(expense);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var orderType = con.OrderTypes.Find(SelectedOrderType.OrderTypeID);
         orderType.Orders.Clear();
         orderType.Specializations = null;
         con.OrderTypes.Remove(orderType);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var specialization = con.Specializations.Find(SelectedSpecialization.SpecializationID);
         specialization.Companies = null;
         specialization.OrderTypes = null;
         con.Specializations.Remove(specialization);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 10
0
        /// <summary>
        /// Adds new item
        /// </summary>
        public override void Add()
        {
            using (var con = new BaudiDbContext())
            {
                var specializations = SpecializationList.Where(s => s.IsSelected).ToList();
                specializations.ForEach(s => con.Specializations.Attach(s));

                OrderType.Specializations = specializations;
                con.OrderTypes.Add(OrderType);
                con.SaveChanges();
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var ownership = con.Ownerships.Find(SelectedOwnership.OwnershipID);
         ownership.Local = null;
         ownership.Owner = null;
         con.Ownerships.Remove(ownership);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var owningCompany = con.OwningCompanies.Find(SelectedOwningCompany.OwnerID);
         owningCompany.Notifications.Clear();
         con.Ownerships.RemoveRange(owningCompany.Ownerships);
         con.OwningCompanies.Remove(owningCompany);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 13
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var company = con.Companies.Find(SelectedCompany.CompanyID);
         company.CyclicOrders.Clear();
         company.Orders.Clear();
         company.Specializations.Clear();
         con.Companies.Remove(company);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var local = con.Locals.Find(SelectedLocal.NotificationTargetID);
         local.Building = null;
         con.Notifications.RemoveRange(local.Notifactions);
         con.Ownerships.RemoveRange(local.Ownerships);
         con.Locals.Remove(local);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 15
0
        /// <summary>
        /// Delete action
        /// </summary>
        public override void Delete()
        {
            using (var con = new BaudiDbContext())
            {
                var cyclicOrder = con.CyclicOrders.Find(SelectedCyclicOrder.ExpenseTargetID);
                cyclicOrder.Building = null;
                cyclicOrder.Company = null;
                con.Expenses.RemoveRange(cyclicOrder.Expenses);
                cyclicOrder.Menager = null;

                con.CyclicOrders.Remove(cyclicOrder);
                con.SaveChanges();
            }
            Update();
        }
Exemplo n.º 16
0
 /// <summary>
 /// Delete action
 /// </summary>
 public override void Delete()
 {
     using (var con = new BaudiDbContext())
     {
         var order = con.Orders.Find(SelectedOrder.ExpenseTargetID);
         order.Company = null;
         con.Expenses.RemoveRange(order.Expenses);
         order.Menager = null;
         order.Notification = null;
         order.OrderType = null;
         con.Orders.Remove(order);
         con.SaveChanges();
     }
     Update();
 }
Exemplo n.º 17
0
        /// <summary>
        /// Delete action
        /// </summary>
        public override void Delete()
        {
            using (var con = new BaudiDbContext())
            {
                var building = con.Buildings.Find(SelectedBuilding.NotificationTargetID);

                building.Locals.ForEach(l => l.Notifactions.ForEach(n => con.Orders.RemoveRange(n.Orders)));
                building.Locals.ForEach(l => con.Notifications.RemoveRange(l.Notifactions));
                building.Locals.ForEach(l => con.Ownerships.RemoveRange(l.Ownerships));
                con.Locals.RemoveRange(building.Locals);

                con.Notifications.RemoveRange(building.Notifactions);
                building.Notifactions.ForEach(n => con.Orders.RemoveRange(n.Orders));

                con.CyclicOrders.RemoveRange(building.CyclicOrders);

                con.Buildings.Remove(building);
                con.SaveChanges();
            }
            Update();
        }
Exemplo n.º 18
0
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         var employee = EmployeeFactory();
         CopyEmployeeState(employee);
         employee.PasswordSalt = SecurityHelper.GeneratePasswordSalt();
         employee.Password = SecurityHelper.ComputeHash(employee.PasswordSalt,
             (EditWindow as EmployeeEditWindow).Password);
         con.Employees.Add(employee);
         con.SaveChanges();
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Adds new item
        /// </summary>
        public override void Add()
        {
            using (var con = new BaudiDbContext())
            {
                var local = con.Locals.Find(SelectedLocal.NotificationTargetID);
                var owner = con.Owners.Find(SelectedOwner.OwnerID);

                Ownership.Local = local;
                Ownership.Owner = owner;

                con.Ownerships.Add(Ownership);
                con.SaveChanges();
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Adds new item
        /// </summary>
        public override void Add()
        {
            using (var con = new BaudiDbContext())
            {
                var ownership = con.Ownerships.Find(SelectedOwnership.OwnershipID);

                Rent.Ownership = ownership;

                con.Rents.Add(Rent);
                con.SaveChanges();
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var ownership = con.Ownerships.Find(SelectedOwnership.OwnershipID);

                var rent = con.Rents.Find(Rent.PaymentID);
                rent.Ownership = ownership;
                rent.Date = Rent.Date;
                rent.Cost = Rent.Cost;
                rent.Paid = Rent.Paid;

                con.Entry(rent).State = EntityState.Modified;

                con.SaveChanges();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var specializations = SpecializationList.Where(s => s.IsSelected).ToList();
                specializations.ForEach(s => con.Specializations.Attach(s));

                var company = con.Companies.Find(Company.CompanyID);
                company.City = Company.City;
                company.HouseNumber = Company.HouseNumber;
                company.LocalNumber = Company.LocalNumber;
                company.Name = Company.Name;
                company.NIP = Company.NIP;
                company.Owner = Company.Owner;

                if (specializations.Count == 0)
                {
                    company.Specializations.Clear();
                }
                else
                {
                    company.Specializations = specializations;
                }
                company.Street = Company.Street;
                company.TelephoneNumber = Company.TelephoneNumber;

                con.Entry(company).State = EntityState.Modified;

                con.SaveChanges();
            }
        }
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var notificationTarget = con.NotificationTargets.Find(SelectedNotificationTarget.NotificationTargetID);
                var owner = con.Owners.Find(SelectedOwner.OwnerID);
                var dispatcher = con.Dispatchers.Find(SelectedDispatcher.OwnerID);

                var notification = con.Notifications.Find(Notification.NotificationID);
                notification.Description = Notification.Description;
                notification.Dispatcher = dispatcher;
                notification.FilingDate = Notification.FilingDate;
                notification.LastChanged = Notification.LastChanged;
                notification.NotificationTarget = notificationTarget;
                notification.Owner = owner;
                notification.Status = SelectedNotificationStatus;

                con.Entry(notification).State = EntityState.Modified;

                con.SaveChanges();
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Adds new item
        /// </summary>
        public override void Add()
        {
            using (var con = new BaudiDbContext())
            {
                var orderType = con.OrderTypes.Find(SelectedOrderType.OrderTypeID);
                var company = con.Companies.Find(SelectedCompany.CompanyID);
                var menager = con.Menagers.Find(SelectedMenager.OwnerID);
                var notification = con.Notifications.Find(SelectedNotification.NotificationID);

                Order.OrderType = orderType;
                Order.Company = company;
                Order.Menager = menager;
                Order.Notification = notification;

                con.Orders.Add(Order);
                con.SaveChanges();
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var local = con.Locals.Find(SelectedLocal.NotificationTargetID);
                var owner = con.Owners.Find(SelectedOwner.OwnerID);

                var ownership = con.Ownerships.Find(Ownership.OwnershipID);
                ownership.PurchaseDate = Ownership.PurchaseDate;
                ownership.SaleDate = ownership.SaleDate;
                ownership.Owner = owner;
                ownership.Local = local;

                con.Entry(ownership).State = EntityState.Modified;

                con.SaveChanges();
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var specializations = SpecializationList.Where(s => s.IsSelected).ToList();
                specializations.ForEach(s => con.Specializations.Attach(s));

                var orderType = con.OrderTypes.Find(OrderType.OrderTypeID);
                orderType.Name = OrderType.Name;

                if (specializations.Count == 0)
                {
                    orderType.Specializations.Clear();
                }
                else
                {
                    orderType.Specializations = specializations;
                }

                con.Entry(orderType).State = EntityState.Modified;

                con.SaveChanges();
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var orderType = con.OrderTypes.Find(SelectedOrderType.OrderTypeID);
                var company = con.Companies.Find(SelectedCompany.CompanyID);
                var menager = con.Menagers.Find(SelectedMenager.OwnerID);
                var notification = con.Notifications.Find(SelectedNotification.NotificationID);

                var order = con.Orders.Find(Order.ExpenseTargetID);
                order.OrderType = orderType;
                order.Company = company;
                order.Menager = menager;
                order.Notification = notification;

                order.Status = SelectedOrderStatus;
                order.Cost = Order.Cost;
                order.LastChanged = Order.LastChanged;
                order.FilingDate = order.FilingDate;
                order.Description = order.Description;

                con.Entry(order).State = EntityState.Modified;

                con.SaveChanges();
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            if (_orginalRole != EmployeeRole)
            {
                using (var con = new BaudiDbContext())
                {
                    var orginalEmployee = con.Employees.Find(Employee.OwnerID);

                    PrepareToChangeEmployeeRole(orginalEmployee);

                    var employee = EmployeeFactory();

                    CopyEmployeeState(employee);

                    employee.Notifications = orginalEmployee.Notifications;
                    orginalEmployee.Notifications = null;
                    employee.Ownerships = orginalEmployee.Ownerships;
                    orginalEmployee.Ownerships = null;
                    employee.Salaries = orginalEmployee.Salaries;
                    orginalEmployee.Ownerships = null;

                    con.Employees.Remove(orginalEmployee);
                    con.Entry(orginalEmployee).State = EntityState.Deleted;

                    con.Employees.Add(employee);
                    con.SaveChanges();
                }
            }
            else
            {
                using (var con = new BaudiDbContext())
                {
                    var employee = con.Employees.Find(Employee.OwnerID);
                    CopyEmployeeState(employee);
                    con.Entry(employee).State = EntityState.Modified;
                    con.SaveChanges();
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var person = con.Peoples.Find(Person.OwnerID);
                person.Name = Person.Name;
                person.Surname = Person.Surname;
                person.PESEL = Person.PESEL;
                person.City = Person.City;
                person.Street = Person.Street;
                person.HouseNumber = Person.HouseNumber;
                person.LocalNumber = Person.LocalNumber;
                person.Telephone = Person.Telephone;

                con.Entry(person).State = EntityState.Modified;
                con.SaveChanges();
            }
        }
        /// <summary>
        /// Adds new item
        /// </summary>
        public override void Add()
        {
            using (var con = new BaudiDbContext())
            {
                var notificationTarget = con.NotificationTargets.Find(SelectedNotificationTarget.NotificationTargetID);
                var owner = con.Owners.Find(SelectedOwner.OwnerID);
                var dispatcher = con.Dispatchers.Find(SelectedDispatcher.OwnerID);

                Notification.NotificationTarget = notificationTarget;
                Notification.Owner = owner;
                Notification.Dispatcher = dispatcher;

                con.Notifications.Add(Notification);
                con.SaveChanges();
            }
        }