public ActionResult SalesOrderLine_Delete([DataSourceRequest] DataSourceRequest request, salesOrderLineModel modelSalesOrderLine) { var iResult = new List <salesOrderLineModel>(); if (!ModelState.IsValid) { iResult.Add(modelSalesOrderLine); } else { try { var iUri = new Uri(ODataWebService.BuildODataUrl()); var iWebService = new NAV(iUri) { Credentials = ODataWebService.CreateCredentials(iUri.ToString()) }; var salesOrderLine = (from lsalesOrderLine in iWebService.salesOrderLines where lsalesOrderLine.id == modelSalesOrderLine.id select lsalesOrderLine).FirstOrDefault(); if (salesOrderLine != null) { iWebService.DeleteObject(salesOrderLine); iWebService.SaveChanges(); } } catch (DataServiceRequestException ex) { ModelState.AddModelError("", ex.Message); iResult.Add(modelSalesOrderLine); } } return(Json(iResult.ToDataSourceResult(request, ModelState))); }
public async Task <IActionResult> OnPostAsync() { _context.Credentials = CredentialCache.DefaultNetworkCredentials; if (!ModelState.IsValid) { return(Page()); } _context.AddToContractCompany(ContractCompany); _context.BeginSaveChanges(adoSave_RLMember, ContractCompany); var company = _context.ContractCompany; DataServiceQuery <ContractCompany> query = company; TaskFactory <IEnumerable <ContractCompany> > taskFactory = new TaskFactory <IEnumerable <ContractCompany> >(); var kompany = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar)); ContractCompany2 = kompany.FirstOrDefault(); _context.DeleteObject(ContractCompany2); _context.BeginSaveChanges(adoSave_RLMember, ContractCompany2); return(RedirectToPage("./Index")); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task <IActionResult> OnPostAsync() #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { _context.Credentials = CredentialCache.DefaultNetworkCredentials; if (!ModelState.IsValid) { return(Page()); } var contract = _context.Contract; DataServiceQuery <Contract> query = contract; TaskFactory <IEnumerable <Contract> > taskFactory = new TaskFactory <IEnumerable <Contract> >(); var kontrakt = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar)); Contract2 = kontrakt.FirstOrDefault(); _context.DeleteObject(Contract2); _context.BeginSaveChanges(adoSave_RLMember, Contract2); _context.AddToContract(Contract); _context.BeginSaveChanges(adoSave_RLMember, Contract); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { _context.Credentials = CredentialCache.DefaultNetworkCredentials; if (id == null) { return(NotFound()); } var contracts = _context.Contract; DataServiceQuery <Contract> query = contracts; TaskFactory <IEnumerable <Contract> > taskFactory = new TaskFactory <IEnumerable <Contract> >(); var kontract = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar)); Contract = kontract.SingleOrDefault(m => m.Contract_No == id); //_context.AttachTo("Contracts", Contract); //_context.AddLink(Contract, "Contract_No", Contract); _context.DeleteObject(Contract); _context.BeginSaveChanges(adoSave_RLMember, Contract); return(RedirectToPage("./Index")); }