internal static String Save(DB.GLX_SiteAccount entry, DataContext dataContext) { try { if (dataContext.EntityAccountingContext.GetEntityState(entry) == EntityState.Detached) { dataContext.EntityAccountingContext.GLX_SiteAccount.Add(entry); } } catch (Validation.EntityValidationException ex) { return(dataContext.PackageValidationException()); } return("Success"); }
public SiteAccounts() { Site = ApplicationDataContext.Instance.SystemEntityContext.SYS_Site.Include("SYS_Entity").FirstOrDefault(n => n.SYS_Entity.Id == ApplicationDataContext.Instance.LoggedInUser.DefaultSiteId); SiteEntity = Site.SYS_Entity; List <int> siteTypes = Enum.GetValues(typeof(GLX.GLX_SystemAccountType)).Cast <int>().ToList(); //SEAN: //removed && n.SystemDefaultAccount == true here List <DB.GLX_SiteAccount> siteAccounts = ApplicationDataContext.Instance.AccountingEntityContext.GLX_SiteAccount.Where(n => siteTypes.Contains(n.TypeId) && n.SiteId == Site.EntityId).ToList(); bank = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Bank); cardControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CardControl); cashControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CashControl); chequeControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.ChequeControl); costDifference = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CostDifference); costOfSales = costOfSales = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CostofSales); creditControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.CreditControl); creditors = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Creditors); if (creditors != null) { creditorsEntity = ApplicationDataContext.Instance.SystemEntityContext.SYS_Entity.FirstOrDefault(n => n.Id == creditors.EntityId); } debtors = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Debtors); if (debtors != null) { debtorsEntity = ApplicationDataContext.Instance.SystemEntityContext.SYS_Entity.FirstOrDefault(n => n.Id == debtors.EntityId); } distributedReserves = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Distributedreserves); eftControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Eftcontrol); interestCharged = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.InterestCharged); inventory = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Inventory); profit = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Profit); rounding = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Rounding); sales = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.Sales); settlemetnDiscountAllowed = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.SettlementDiscountAllowed); settlemetnDiscountRecieved = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.SettlementDiscountReceived); stockAdjustment = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.StockAdjustment); vatControl = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.VatControl); vatInput = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.VatInput); vatOutput = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.VatOutput); inventoryBuyout = siteAccounts.FirstOrDefault(n => n.TypeId == (byte)GLX.GLX_SystemAccountType.InventoryBuyout); }
public static String Delete(DB.GLX_SiteAccount entry, DataContext dataContext) { try { if (dataContext.EntityAccountingContext.GetEntityState(entry) != EntityState.Detached) { dataContext.EntityAccountingContext.GLX_SiteAccount.Remove(entry); } Validation.ValidateEntity(dataContext.EntityAccountingContext, entry); } catch (Validation.EntityValidationException ex) { return(dataContext.PackageValidationException()); } return("Success"); }