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; } }
public void CRM_Query_WorkDoneItem_CrUD() { // Create Account createAccount(accountName); var account = getAccount(accountName); // Create Opportunity createOpportunity(opportunityName, account); var opportunity = getOpportunity(opportunityName); // Create Invoice createInvoice(invoiceName, opportunity); var invoice = getInvoice(invoiceName); // Create Work Done Item var item = new WorkDoneItem() { AccountId = account.Id, InvoiceId = invoice.Id, WorkDoneDate = new DateTime(2005, 5, 1), Margin = (decimal?)12345.67 }; var id = wdiQuery.Create(item); // Check item item = wdiQuery.GetItem(id); Assert.AreEqual(account.Id, item.AccountId); Assert.AreEqual(invoice.Id, item.InvoiceId); Assert.AreEqual(new DateTime(2005, 5, 1), item.WorkDoneDate); Assert.AreEqual((decimal?)12345.67, item.Margin); // Delete Work Done Item var invoiceId = wdiQuery.Delete(id); Assert.AreEqual(invoice.Id, invoiceId); // Delete Others deleteInvoice(invoiceName); deleteOpportunity(opportunityName); deleteAccount(accountName); context.SaveChanges(); }