Beispiel #1
0
        public void BulkUpdate(WorkDoneItem workDoneItem)
        {
            var workDoneItemEntity =
                Context.WorkDoneItems.SingleOrDefault(a =>
                                                      a.InvoiceId == workDoneItem.InvoiceId &&
                                                      a.WorkDoneDate == workDoneItem.WorkDoneDate);

            if (workDoneItemEntity == null)
            {
                var workDoneItemQuery = new WorkDoneItemQuery(Context);

                workDoneItem.Id = workDoneItemQuery.Create(workDoneItem);
            }
            else
            {
                workDoneItem.Id = workDoneItemEntity.Id;
            }
        }
Beispiel #2
0
        private void UpdateWorkDoneItems(InvoiceEntity entity, Invoice invoice)
        {
            var workDoneItemQuery = new WorkDoneItemQuery(Context);

            foreach (var item in invoice.WorkDoneItems)
            {
                if (item.Margin.HasValue)
                {
                    item.AccountId = entity.AccountId;
                    item.InvoiceId = entity.Id;

                    if (item.Id.HasValue)
                    {
                        workDoneItemQuery.Update(item);
                    }
                    else
                    {
                        workDoneItemQuery.Create(item);
                    }
                }
            }
        }