Esempio n. 1
0
        public static void Update(Invoices invoice, decimal?value, int?stairCaseId, string description, int?redistributionId,
                                  string issueNumber, DateTime?issueDate)
        {
            Invoices result;

            result = GetContext(true).Invoices.FirstOrDefault(c => c.Id == invoice.Id);

            if (result != null)
            {
                result.Value                 = value;
                result.Description           = description;
                result.Id_StairCase          = stairCaseId;
                result.id_Redistributiontype = redistributionId;
                result.issueDate             = issueDate;
                result.issueNumber           = issueNumber;

                GetContext().Entry(result).CurrentValues.SetValues(result);

                if (invoice.Id_EstateExpense.HasValue)
                {
                    var ee = AssociationExpensesManager.GetById(invoice.Id_EstateExpense.Value);
                    if (ee != null && ee.Id_Expense != (int)Expense.Diverse)
                    {
                        ApartmentExpensesManager.UpdateApartmentExpenses(ee, value, stairCaseId, result.id_assCounter);
                    }
                }

                GetContext().SaveChanges();
            }
        }
Esempio n. 2
0
        private static void RelalculateExpense(AssociationExpenses item)
        {
            switch (item.Id_ExpenseType)
            {
            case (int)ExpenseType.PerNrTenants:
            case (int)ExpenseType.PerCotaIndiviza:
                if (item.Invoices.Count != 1)
                {
                    return;
                }
                var invoice = item.Invoices.FirstOrDefault();
                if (invoice != null && invoice.Value.HasValue)
                {
                    ApartmentExpensesManager.UpdateApartmentExpenses(invoice.AssociationExpenses, invoice.Value.Value, null);
                }

                break;

            case (int)ExpenseType.PerIndex:
                //redistribute
                break;
            }
        }