Ejemplo n.º 1
0
 /// <summary>
 /// Load data from database
 /// </summary>
 public void LoadData()
 {
     using (var con = new BaudiDbContext())
     {
         FindData(con);
     }
 }
        public NotificationEditWindowViewModel(NotificationsTabViewModel notificationTabViewModel,
            NotificationEditWindow notificationEditWindow, Notification notification)
            : base(notificationTabViewModel, notificationEditWindow, notification)
        {
            using (var con = new BaudiDbContext())
            {
                NotificationTargetsList = con.NotificationTargets.ToList();
                OwnersList = con.Owners.ToList();
                DispatchersList = con.Dispatchers.ToList();
                if (Update)
                {
                    Notification = con.Notifications.Find(notification.NotificationID);
                    SelectedNotificationStatus = Notification.Status;
                    SelectedNotificationTarget = Notification.NotificationTarget;
                    SelectedOwner = Notification.Owner;
                    SelectedDispatcher = Notification.Dispatcher;
                }
                else
                {
                    Notification = new Notification();
                    Notification.FilingDate = DateTime.Now;
                    Notification.LastChanged = DateTime.Now;

                }
            }
        }
Ejemplo n.º 3
0
        public OrderEditWindowViewModel(OrdersTabViewModel orderTabViewModel, OrderEditWindow orderEditWindow,
            Order order)
            : base(orderTabViewModel, orderEditWindow, order)
        {
            CompaniesList = new List<Company>();
            using (var con = new BaudiDbContext())
            {
                OrderTypesList = con.OrderTypes.ToList();
                MenagersList = con.Menagers.ToList();
                CompaniesList = con.Companies.ToList();
                NotificationsList = con.Notifications.ToList();
                if (Update)
                {
                    Order = con.Orders.Find(order.ExpenseTargetID);
                    SelectedOrderType = Order.OrderType;

                    var companies = new List<Company>();
                    var orderType = con.OrderTypes.Find(SelectedOrderType.OrderTypeID);
                    orderType.Specializations.ForEach(s => companies.AddRange(s.Companies));
                    CompaniesList = companies;

                    SelectedCompany = Order.Company;
                    SelectedMenager = Order.Menager;
                    SelectedNotification = Order.Notification;
                    SelectedOrderStatus = Order.Status;

                }
                else
                {
                    Order = new Order();
                    Order.FilingDate = DateTime.Now;
                    Order.LastChanged = DateTime.Now;
                }
            }
        }
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         con.Specializations.Add(Specialization);
         con.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         con.Buildings.Add(Building);
         con.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds new item
 /// </summary>
 public override void Add()
 {
     using (var con = new BaudiDbContext())
     {
         con.Peoples.Add(Person);
         con.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Load action
 /// </summary>
 public override void Load()
 {
     using (var con = new BaudiDbContext())
     {
         OrderTypesList = con.OrderTypes
             .ToList();
     }
 }
Ejemplo n.º 8
0
 protected override void FindData(BaudiDbContext con)
 {
     var groupedRents = con.Rents
         .Where(s =>(s.Ownership.Local.Building.NotificationTargetID == BuildingId) && (s.Date >= DateFrom && s.Date <= DateTo))
         .GroupBy(r => r.Ownership.Owner);
     foreach (var group in groupedRents)
     {
         RentTables.Add(new RentTable(group));
     }
 }
        /// <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();
            }
        }
Ejemplo n.º 10
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();
 }
Ejemplo n.º 11
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();
 }
Ejemplo n.º 12
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();
 }
Ejemplo n.º 13
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();
 }
Ejemplo n.º 14
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();
 }
Ejemplo n.º 15
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();
 }
Ejemplo n.º 16
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));

                Company.Specializations = specializations;
                con.Companies.Add(Company);
                con.SaveChanges();
            }
        }
Ejemplo n.º 17
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();
 }
Ejemplo n.º 18
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();
 }
Ejemplo n.º 19
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();
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Edits item
        /// </summary>
        public override void Edit()
        {
            using (var con = new BaudiDbContext())
            {
                var building = con.Buildings.Find(Building.NotificationTargetID);
                building.City = Building.City;
                building.HouseNumber = Building.HouseNumber;
                building.Street = Building.Street;

                con.Entry(building).State = EntityState.Modified;
                con.SaveChanges();
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Report tab view model constructor
 /// </summary>
 public ReportsTabViewModel()
 {
     ButtonGenerate = new RelayCommand(pars => Generate(), pars =>IsValid());
     _dateFrom = DateTime.Now;
     _dateTo = DateTime.Now;
     PropertyChanged += OnReportTypeChange;
     _reportType = ReportType.SalaryReport;
     using (var con = new BaudiDbContext())
     {
         BuildingsList = con.Buildings.ToList();
     }
     SelectedBuilding = BuildingsList.FirstOrDefault();
 }
Ejemplo n.º 22
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();
        }
Ejemplo n.º 23
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();
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Adds new item
        /// </summary>
        public override void Add()
        {
            using (var con = new BaudiDbContext())
            {
                var building = con.Buildings.Find(SelectedBuilding.NotificationTargetID);

                Local.LocalNumber = Local.LocalNumber;
                Local.RentValue = Local.RentValue;
                Local.NumberOfRooms = Local.NumberOfRooms;
                Local.Area = Local.Area;
                Local.Building = building;

                con.Locals.Add(Local);
                con.SaveChanges();
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Find data in database
        /// </summary>
        /// <param name="con">data context</param>
        protected override void FindData(BaudiDbContext con)
        {
            var allCyclicOrders = con.Buildings.Find(BuildingId).CyclicOrders.Where(c => c.Expenses.Any( e => e.Date >= DateFrom && e.Date <= DateTo));
            var allOrders = con.Orders.Where(
                o => (o.Notification.NotificationTarget.NotificationTargetID == BuildingId
                || con.Locals.Where(l => l.Building.NotificationTargetID == BuildingId).Select(l => l.NotificationTargetID).Contains(o.Notification.NotificationTarget.NotificationTargetID))
                && o.Expenses.Any(e => e.Date >= DateFrom && e.Date <= DateTo));

            foreach (var cyclicOrder in allCyclicOrders)
            {
                ExpenseTables.Add(new ExpenseTable(cyclicOrder, DateFrom, DateTo));
            }
            foreach (var order in allOrders)
            {
                ExpenseTables.Add(new ExpenseTable(order, DateFrom, DateTo));
            }
        }
Ejemplo n.º 26
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();
            }
        }
Ejemplo n.º 27
0
 public LocalEditWindowViewModel(LocalsTabViewModel localTabViewModel, LocalEditWindow localEditWindow,
     Local local)
     : base(localTabViewModel, localEditWindow, local)
 {
     using (var con = new BaudiDbContext())
     {
         BuildingsList = con.Buildings.ToList();
         if (Update)
         {
             Local = con.Locals.Find(local.NotificationTargetID);
             SelectedBuilding = Local.Building;
         }
         else
         {
             Local = new Local();
         }
     }
 }
Ejemplo n.º 28
0
 public RentEditWindowViewModel(RentsTabViewModel rentsTabViewModel, RentEditWindow rentEditWindow, Rent rent)
     : base(rentsTabViewModel, rentEditWindow, rent)
 {
     using (var con = new BaudiDbContext())
     {
         OwnershipsList = con.Ownerships.ToList();
         if (Update)
         {
             Rent = con.Rents.Find(rent.PaymentID);
             SelectedOwnership = Rent.Ownership;
         }
         else
         {
             Rent = new Rent();
             Rent.Date = DateTime.Now;
         }
     }
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="companiesTabViewModel">Company tab view Model </param>
 /// <param name="companyEditWindow"> Company edit window</param>
 /// <param name="company">Company</param>
 public CompanyEditWindowViewModel(CompaniesTabViewModel companiesTabViewModel,
     CompanyEditWindow companyEditWindow, Company company)
     : base(companiesTabViewModel, companyEditWindow, company)
 {
     using (var con = new BaudiDbContext())
     {
         SpecializationList = con.Specializations.ToList();
         if (Update)
         {
             Company = con.Companies.Find(company.CompanyID);
             Company.Specializations.ForEach(s => s.IsSelected = true);
         }
         else
         {
             Company = new Company();
         }
     }
 }
Ejemplo n.º 30
0
 public OrderTypeEditWindowViewModel(OrderTypesTabViewModel orderTypeTabViewModel,
     OrderTypeEditWindow orderTypeEditWindow, OrderType orderType)
     : base(orderTypeTabViewModel, orderTypeEditWindow, orderType)
 {
     using (var con = new BaudiDbContext())
     {
         SpecializationList = con.Specializations.ToList();
         if (Update)
         {
             OrderType = con.OrderTypes.Find(orderType.OrderTypeID);
             OrderType.Specializations.ForEach(s => s.IsSelected = true);
         }
         else
         {
             OrderType = new OrderType();
         }
     }
 }