public static bool InsertOrganisationComm(EvolutionRepository.Models.OrganisationComm newOrgCom) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { var orgCom = new EvolutionRepository.Models.OrganisationComm(); orgCom.OrganisationCommTypeID = newOrgCom.OrganisationCommTypeID; orgCom.OrganisationID = newOrgCom.OrganisationID; orgCom.Address = newOrgCom.Address; orgCom.AddressPrefix = newOrgCom.AddressPrefix; orgCom.CommsHoneymoon = newOrgCom.CommsHoneymoon; ctx.OrganisationComms.Add(orgCom); ctx.SaveChanges(); Result = true; } } catch (Exception) { Result = false; } return(Result); }
//Banking Details public static bool SaveBankingDetails(EvolutionRepository.Models.BankAccount bankAcc) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Database.ExecuteSqlCommand("evo_BankAccountsSave @OrganisationID,@AccountHolder,@AccountNumber,@BankID,@Branch,@BranchCode,@AccountTypeID", new SqlParameter("@OrganisationID", bankAcc.OrganisationID), new SqlParameter("@AccountHolder", bankAcc.AccountHolder), new SqlParameter("@AccountNumber", bankAcc.AccountNumber), new SqlParameter("@BankID", bankAcc.BankID), new SqlParameter("@Branch", bankAcc.Branch), new SqlParameter("@BranchCode", bankAcc.BranchCode), new SqlParameter("@AccountTypeID", bankAcc.AccountTypeID) ); } Result = true; } catch (Exception ex) { Result = false; throw ex; } return(Result); }
public static bool AddArea(EvolutionRepository.Models.Area newArea) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { var DBArea = ctx.Areas.FirstOrDefault(x => x.AreaID == newArea.AreaID); if (DBArea == null) { DBArea = new EvolutionRepository.Models.Area();// ctx.Areas; DBArea.AreaName = newArea.AreaName; DBArea.Mobile = newArea.Mobile; DBArea.OrganisationID = newArea.OrganisationID; DBArea.Telephone = newArea.Telephone; DBArea.Total_Engineers_Allocated = newArea.Total_Engineers_Allocated; DBArea.Total_staff_Allocted = newArea.Total_staff_Allocted; DBArea.Total_Vehicles_Allocated = newArea.Total_Vehicles_Allocated; DBArea.EmployeeID = newArea.EmployeeID; DBArea.EmergencyNumber = newArea.EmergencyNumber; ctx.Areas.Add(DBArea); ctx.SaveChanges(); } Result = true; } } catch (Exception) { Result = false; } return(Result); }
public static bool SaveRevenueProfile(EvolutionRepository.Models.RevenueProfile revProfile) { bool Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Database.ExecuteSqlCommand("sp_SaveRevenueProfile @RevenueProfileID,@RevenueProfileName,@OrganisationID,@DeductionTotalTypeID," + "@AppliesOrganisationTypeID,@CollectOrganisationTypeID,@RevenueProfileTypeID,@DeductionTypeID,@CreditOrganisationTypeID,@IsSplit", new SqlParameter("@RevenueProfileID", revProfile.RevenueProfileID), new SqlParameter("@RevenueProfileName", revProfile.RevenueProfileName), new SqlParameter("@OrganisationID", revProfile.OrganisationID), new SqlParameter("@DeductionTotalTypeID", revProfile.DeductionTotalTypeID), new SqlParameter("@AppliesOrganisationTypeID", revProfile.AppliesOrganisationTypeID), new SqlParameter("@CollectOrganisationTypeID", revProfile.CollectOrganisationTypeID), new SqlParameter("@RevenueProfileTypeID", revProfile.RevenueProfileTypeID), new SqlParameter("@DeductionTypeID", revProfile.DeductionTypeID), new SqlParameter("@CreditOrganisationTypeID", revProfile.CreditOrganisationTypeID), new SqlParameter("@IsSplit", false)); } } catch (Exception ex) { throw ex; } return(Result); }
public static EvolutionRepository.ManualModels.GetDepartmentListResult GetAllDepartmentsByID(int organisationID, int skip, int take) { try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { int TotalInstancesWithoutSkipTake; ctx.Configuration.ProxyCreationEnabled = false; var departmentList = ctx.Departments.Where(p => p.OrganisationID == organisationID).ToList(); if (departmentList != null) { TotalInstancesWithoutSkipTake = departmentList.Count(); departmentList = departmentList.OrderBy(x => x.DepartmentID).Skip(skip).Take(take).ToList(); return(new EvolutionRepository.ManualModels.GetDepartmentListResult(departmentList.ToArray(), TotalInstancesWithoutSkipTake)); } return(null); } } catch (Exception) { throw; } }
public static bool SaveDailyDeductions(EvolutionRepository.Models.DailyDeduction dailyDeduction) { bool Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Database.ExecuteSqlCommand("Evo_DailyDeductionsSave @MachineID,@ApplicableDate,@RevenueProfileID," + "@SiteID,@CollectionOrganisationID,@CreditOrganisationID,@RatePercent,@Amount", new SqlParameter("@MachineID", dailyDeduction.MachineID), new SqlParameter("@ApplicableDate", dailyDeduction.ApplicableDate), new SqlParameter("@RevenueProfileID", dailyDeduction.RevenueProfileID), new SqlParameter("@SiteID", dailyDeduction.SiteID), new SqlParameter("@CollectionOrganisationID", dailyDeduction.CollectionOrganisationID), new SqlParameter("@CreditOrganisationID", dailyDeduction.CollectionOrganisationID), new SqlParameter("@RatePercent", dailyDeduction.RatePercent), new SqlParameter("@Amount", dailyDeduction.Amount)); } Result = true; } catch (Exception ex) { throw ex; } return(Result); }
public static bool CreateEmployee(EvolutionRepository.Models.Employee CreateEmp) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { if (Object.Equals(null, ctx.Employees.FirstOrDefault(x => x.EmployeeID == CreateEmp.EmployeeID))) { ctx.Employees.Add(CreateEmp); ctx.SaveChanges(); } Result = true; } } catch (DbEntityValidationException ex) { // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(ErrorHandler.BuildDbEntityValidationErrorMessage(ex), ex.EntityValidationErrors); } catch (Exception ex) { Result = false; throw ex; } return(Result); }
public static EvolutionRepository.ManualModels.GetOrgTreeListResult GetOrganisationsInTree(int TopOrganisationID) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Configuration.ProxyCreationEnabled = false; var Result = new EvolutionRepository.ManualModels.GetOrgTreeListResult(); var OrgTreeList = ctx.OrgTrees.Where(p => p.TopOrganisationID == TopOrganisationID).OrderBy(x => x.OrganisationName).ToList(); if (OrgTreeList != null) { Result.Count = ctx.OrgTrees.Where(p => p.TopOrganisationID == TopOrganisationID).Count(); var orgTreeManualList = new List <EvolutionRepository.ManualModels.OrgTree>(); foreach (var item in OrgTreeList) { orgTreeManualList.Add(new EvolutionRepository.ManualModels.OrgTree { OrganisationID = item.OrganisationID, OrganisationName = item.OrganisationName }); } Result.Data = orgTreeManualList; return(Result); } return(null); } }
public static bool EditOrganisationComm(EvolutionRepository.Models.OrganisationComm updatedOrgCom) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { var orgCom = ctx.OrganisationComms.FirstOrDefault(x => x.OrganisationCommID == updatedOrgCom.OrganisationCommID); orgCom.OrganisationCommTypeID = updatedOrgCom.OrganisationCommTypeID; orgCom.OrganisationID = updatedOrgCom.OrganisationID; orgCom.Address = updatedOrgCom.Address; orgCom.AddressPrefix = updatedOrgCom.AddressPrefix; orgCom.CommsHoneymoon = updatedOrgCom.CommsHoneymoon; ctx.SaveChanges(); Result = true; } } catch (Exception) { Result = false; } return(Result); }
public static bool SaveRevenueProfileSplits(EvolutionRepository.ManualModels.RevenueProfileSimple simpleProfile) { bool Result = false; try { //simpleProfile.SiteSplit //simpleProfile.OperatorSplit using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Database.ExecuteSqlCommand("Evo_SaveRevenueProfileSplits @RevenueProfileID,@RevenueProfileName,@OrganisationID,@DeductionTotalTypeID,@AppliesOrganisationTypeID," + "@CollectOrganisationTypeID,@RevenueProfileTypeID,@DeductionTypeID,@CreditOrganisationTypeID,@IsSplit,@SiteSplit,@OperatorSplit", new SqlParameter("@RevenueProfileID", simpleProfile.RevenueProfileID), new SqlParameter("@RevenueProfileName", simpleProfile.RevenueProfileName), new SqlParameter("@OrganisationID", simpleProfile.OrganisationID), new SqlParameter("@DeductionTotalTypeID", simpleProfile.DeductionTotalTypeID), new SqlParameter("@AppliesOrganisationTypeID", simpleProfile.AppliesOrganisationTypeID), new SqlParameter("@CollectOrganisationTypeID", simpleProfile.CollectOrganisationTypeID), new SqlParameter("@RevenueProfileTypeID", simpleProfile.RevenueProfileTypeID), new SqlParameter("@DeductionTypeID", simpleProfile.DeductionTypeID), new SqlParameter("@CreditOrganisationTypeID", simpleProfile.CreditOrganisationTypeID), new SqlParameter("@IsSplit", true), new SqlParameter("@SiteSplit", simpleProfile.SiteSplit), new SqlParameter("@OperatorSplit", simpleProfile.OperatorSplit)); } Result = true; } catch (Exception ex) { throw ex; } return(Result); }
public static EvolutionRepository.Models.OrganisationComm GetOrganisationCommByID(int organisationCommID) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Configuration.ProxyCreationEnabled = false; var result = ctx.OrganisationComms.FirstOrDefault(x => x.OrganisationCommID == organisationCommID); return(result); } }
public static List <EvolutionRepository.Models.AccountType> GetBankAccountTypes() { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { List <EvolutionRepository.Models.AccountType> bankAccountTypes = new List <EvolutionRepository.Models.AccountType>(); bankAccountTypes = ctx.Database.SqlQuery <EvolutionRepository.Models.AccountType>("GetAccountTypes").ToList(); return(bankAccountTypes); } }
public static List <EvolutionRepository.Models.Title> GetTitles() { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Configuration.ProxyCreationEnabled = false; var result = ctx.Titles.ToList(); return(result); } }
public static List <EvolutionRepository.Models.Bank> GetBanks() { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { List <EvolutionRepository.Models.Bank> banks = new List <EvolutionRepository.Models.Bank>(); banks = ctx.Database.SqlQuery <EvolutionRepository.Models.Bank>("Evo_GetBanks").ToList(); return(banks); } }
public static List <EvolutionRepository.Models.DailyDeduction> GetDailyDeductions() { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { List <EvolutionRepository.Models.DailyDeduction> deductions = new List <EvolutionRepository.Models.DailyDeduction>(); deductions = ctx.Database.SqlQuery <EvolutionRepository.Models.DailyDeduction>("Evo_GetDailyDeductions").ToList(); return(deductions); } }
public static EvolutionRepository.Models.Organisation GetOrganisation(int OrgID) { EvolutionRepository.Models.Organisation org = new EvolutionRepository.Models.Organisation(); using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { org = ctx.Database.SqlQuery <EvolutionRepository.Models.Organisation>("Evo_memGetOrganisation @OrganisationID", new SqlParameter("@OrganisationID", OrgID)).FirstOrDefault(); return(org); //ctx.Organisations.Where(o => o.OrganisationID == OrgID).FirstOrDefault(); } }
public static EvolutionRepository.Models.BankAccount GetOrganisationBankingDetails(int OrganisationId) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { EvolutionRepository.Models.BankAccount bankAccounts = new EvolutionRepository.Models.BankAccount(); bankAccounts = ctx.Database.SqlQuery <EvolutionRepository.Models.BankAccount>("evo_GetOrganisationBankAccounts @OrganisationId", new SqlParameter("@OrganisationID", OrganisationId)).FirstOrDefault(); return(bankAccounts); } }
public static EvolutionRepository.ManualModels.GetRevenueProfileScaleResult GetRevenueProfileScales(int revenueProfileID) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { EvolutionRepository.ManualModels.GetRevenueProfileScaleResult result = new EvolutionRepository.ManualModels.GetRevenueProfileScaleResult(); result.data = ctx.Database.SqlQuery <EvolutionRepository.Models.RevenueScale>("Evo_GetRevenueProfileScales @profileID", new SqlParameter("@profileID", revenueProfileID)).ToList(); result.count = result.data.Count(); return(result); } }
public static List <EvolutionRepository.Models.OrgTree> GetOrgTree(string sessionID) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Configuration.ProxyCreationEnabled = false; var userSession = ctx.UserSessions.Where(p => p.SessionID == sessionID).First(); var result = ctx.OrgTrees.Where(p => p.TopOrganisationID == userSession.TopOrganisationID).OrderBy(p => p.OrganisationName).ToList(); return(result); } }
public static GetOrganisationCommListResult GetAllOrganisationCommsByID(int organisationID, int skip, int take) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Configuration.ProxyCreationEnabled = false; var Result = new GetOrganisationCommListResult(); Result.count = ctx.Users.Count(); Result.data = ctx.OrganisationComms.Where(p => p.OrganisationID == organisationID).OrderBy(x => x.OrganisationCommID).Skip(skip).Take(take).ToList(); return(Result); } }
public static EvolutionRepository.ManualModels.GetOrganistionListResult GetOrganisations(int skip, int take) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Configuration.ProxyCreationEnabled = false; var Result = new EvolutionRepository.ManualModels.GetOrganistionListResult(); Result.count = ctx.Organisations.Count(); Result.data = ctx.Organisations.OrderBy(x => x.OrganisationID).Skip(skip).Take(take).ToList(); return(Result); } }
public static List <EvolutionRepository.Models.BankAccount> GetBankAccounts() { try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { return(ctx.BankAccounts.ToList()); } } catch (Exception ex) { throw ex; } }
public static void CreateUserSession(EvolutionRepository.ManualModels.UserSession userSession) { try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { ctx.Database.ExecuteSqlCommand("Evo_UserSessionsCreate @SessionID, @UserName", new SqlParameter("@SessionID", userSession.SessionID), new SqlParameter("@UserName", userSession.UserName)); } } catch (Exception ex) { throw ex; } }
public static List <EvolutionRepository.Models.Jurisdiction> GetJurisdictions() { List <EvolutionRepository.Models.Jurisdiction> jurisdictions = new List <EvolutionRepository.Models.Jurisdiction>(); try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { return(ctx.Jurisdictions.ToList()); } } catch (Exception ex) { throw ex; } }
public static List <EvolutionRepository.Models.RevenueProfileType> GetRevenueProfileType() { try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { List <EvolutionRepository.Models.RevenueProfileType> profileTypes = new List <EvolutionRepository.Models.RevenueProfileType>(); profileTypes = ctx.Database.SqlQuery <EvolutionRepository.Models.RevenueProfileType>("GetRevenueProfileTypes").ToList(); return(profileTypes); } } catch (Exception ex) { throw ex; } }
public static List <EvolutionRepository.Models.DeductionTotalType> GetDeductionTotalType() { try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { List <EvolutionRepository.Models.DeductionTotalType> deductionTotalType = new List <EvolutionRepository.Models.DeductionTotalType>(); deductionTotalType = ctx.Database.SqlQuery <EvolutionRepository.Models.DeductionTotalType>("GetDeductionTotalTypes").ToList(); return(deductionTotalType); } } catch (Exception ex) { throw ex; } }
public static bool DeleteOrganisation(int i) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { } } catch (Exception ex) { throw ex; } return(Result); }
public static List <EvolutionRepository.Models.OrganisationStatu> GetOrgStatuses() { try { List <EvolutionRepository.Models.OrganisationStatu> orgStatuses = new List <EvolutionRepository.Models.OrganisationStatu>(); using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { orgStatuses = ctx.Database.SqlQuery <EvolutionRepository.Models.OrganisationStatu>("Evo_memGetOrganisationStatuses").ToList(); return(orgStatuses); //return ctx.OrganisationStatus.ToList(); } } catch (Exception ex) { throw ex; } }
public static List <EvolutionRepository.Models.Jurisdiction> GetJurisdictions() { List <EvolutionRepository.Models.Jurisdiction> jurisdictions = new List <EvolutionRepository.Models.Jurisdiction>(); try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { jurisdictions = ctx.Database.SqlQuery <EvolutionRepository.Models.Jurisdiction>("Evo_memGetJurisdictions").ToList(); return(jurisdictions); //return ctx.Jurisdictions.ToList(); } } catch (Exception ex) { throw ex; } }
public static EvolutionRepository.ManualModels.GetSplitListResult GetAllOrganisationSplits(int organisationID, int skip, int take) { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { int TotalInstancesWithoutSkipTake; ctx.Configuration.ProxyCreationEnabled = false; var splitList = ctx.RevenueProfiles.Where(p => p.OrganisationID == organisationID && p.IsSplit == 1).ToList(); if (splitList != null) { TotalInstancesWithoutSkipTake = splitList.Count(); splitList = splitList.OrderBy(x => x.RevenueProfileID).Skip(skip).Take(take).ToList(); var splitManualList = new List <EvolutionRepository.ManualModels.RevenueProfileSimple>(); foreach (var item in splitList) { splitManualList.Add(new EvolutionRepository.ManualModels.RevenueProfileSimple { DateAdded = item.DateAdded, RevenueProfileID = item.RevenueProfileID, RevenueProfileName = item.RevenueProfileName, RevenueProfileTypeID = item.RevenueProfileTypeID.Value, RevenueProfileTypeName = ctx.RevenueProfileTypes.Where(p => p.RevenueProfileTypeID == item.RevenueProfileTypeID).FirstOrDefault().RevenueProfileTypeName, DeductionTypeID = item.DeductionTypeID.Value, DeductionTypeName = ctx.DeductionTypes.Where(p => p.DeductionTypeID == item.DeductionTypeID.Value).FirstOrDefault().DeductionTypeName, DeductionTotalTypeID = item.DeductionTotalTypeID.Value, DeductionTotalTypeName = ctx.DeductionTotalTypes.Where(p => p.DeductionTotalTypeID == item.DeductionTotalTypeID.Value).FirstOrDefault().DeductionTotalTypeName, AppliesOrganisationTypeID = item.AppliesOrganisationTypeID.Value, AppliesOrganisationTypeName = ctx.OrganisationTypes.Where(p => p.OrganisationTypeID == item.AppliesOrganisationTypeID.Value).FirstOrDefault().OrganisationTypeName, CollectOrganisationTypeID = item.CollectOrganisationTypeID.Value, CollectOrganisationTypeName = ctx.OrganisationTypes.Where(p => p.OrganisationTypeID == item.CollectOrganisationTypeID.Value).FirstOrDefault().OrganisationTypeName, CreditOrganisationTypeID = item.CreditOrganisationTypeID.Value, CreditOrganisationTypeName = ctx.OrganisationTypes.Where(p => p.OrganisationTypeID == item.CreditOrganisationTypeID.Value).FirstOrDefault().OrganisationTypeName, SiteSplit = 100 - ctx.RevenueScales.Where(s => s.RevenueProfileID == item.RevenueProfileID && s.RevenueScaleID == 0).FirstOrDefault().Rate, OperatorSplit = ctx.RevenueScales.Where(s => s.RevenueProfileID == item.RevenueProfileID && s.RevenueScaleID == 0).FirstOrDefault().Rate }); } return(new EvolutionRepository.ManualModels.GetSplitListResult(splitManualList.ToArray(), TotalInstancesWithoutSkipTake)); } return(null); } }