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); }
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 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 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 UpdateEmployee(EvolutionRepository.Models.Employee UpdateEmp) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { var DBEmp = ctx.Employees.FirstOrDefault(x => x.EmployeeID == UpdateEmp.EmployeeID); //DBEmp.BankAccountID = UpdateEmp.BankAccountID; //DBEmp.CompanyNumber = UpdateEmp.CompanyNumber; //DBEmp.ContactName = UpdateEmp.ContactName; //DBEmp.EmailAddress = UpdateEmp.EmailAddress; //DBEmp.FaxCode = UpdateEmp.FaxCode; //DBEmp.FaxNumber = UpdateEmp.FaxNumber; //DBEmp.JurisdictionID = UpdateEmp.JurisdictionID; //DBEmp.Latitude = UpdateEmp.Latitude; //DBEmp.Longitude = UpdateEmp.Longitude; //DBEmp.MaximumMachines = UpdateEmp.MaximumMachines; //DBEmp.EmployeeName = UpdateEmp.EmployeeName; //DBEmp.EmployeeStatusID = UpdateEmp.EmployeeStatusID; //DBEmp.EmployeeSubTypeID = UpdateEmp.EmployeeSubTypeID; //DBEmp.EmployeeTypeID = UpdateEmp.EmployeeTypeID; //DBEmp.ParentID = UpdateEmp.ParentID; //DBEmp.TaxNumber = UpdateEmp.TaxNumber; //DBEmp.TelephoneCode = UpdateEmp.TelephoneCode; //DBEmp.TelephoneNumber = UpdateEmp.TelephoneNumber; //DBEmp.Timestamp = System.Text.ASCIIEncoding.Unicode.GetBytes(DateTime.Now.ToString()); //DBEmp.WebSiteURL = UpdateEmp.WebSiteURL; ctx.SaveChanges(); Result = true; } } catch (Exception ex) { Result = false; throw ex; } return(Result); }
public static bool DeleteOrganisationComm(int organisationCommID) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { var orgCom = ctx.OrganisationComms.FirstOrDefault(x => x.OrganisationCommID == organisationCommID); ctx.OrganisationComms.Remove(orgCom); ctx.SaveChanges(); Result = true; } } catch (Exception) { Result = false; } return(Result); }
public static bool DeleteArea(int areaID) //EvolutionRepository.Models.Area AddArea) { var Result = false; try { using (var ctx = new EvolutionRepository.Models.EvolutionDBContext()) { var DBArea = ctx.Areas.FirstOrDefault(x => x.AreaID == areaID); if (DBArea != null) { ctx.Areas.Remove(DBArea); ctx.SaveChanges(); } Result = true; } } catch (Exception) { Result = false; } return(Result); }