private bool DeletedAxComination(tbl_AccessoryAttributesDetails detailsToUpdate, int userIserial) { var axapta = new Axapta(); //Ready To be Dependent from Ax; var credential = new NetworkCredential("bcproxy", "around1"); //Ready To be Dependent from Ax bool result = false; TblAuthUser userToLogin; using (var model = new WorkFlowManagerDBEntities()) { userToLogin = model.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial); } axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null); try { var importNew = axapta.CreateAxaptaObject("CreateProductionJournals"); result = (bool)importNew.Call("DeleteInventDimCombination", detailsToUpdate.tbl_AccessoryAttributesHeader.Code, detailsToUpdate.Configuration, detailsToUpdate.Size); } catch (Exception) { } axapta.Logoff(); return(result); }
private int DeleteAccDetail(tbl_AccessoryAttributesDetails row, int userIserial) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.tbl_AccessoryAttributesDetails.Include(nameof(tbl_AccessoryAttributesDetails.tbl_AccessoryAttributesHeader)) where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { if (SharedOperation.UseAx()) { if (!DeletedAxComination(oldRow, userIserial)) { return(0); } } context.DeleteObject(oldRow); context.SaveChanges(); } } return(row.Iserial); }