protected string getPersonToVisit(object id, SharedClass.RelationType relation) { using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities()) { var visitingFile = mc.Petient_Visiting_Financials.Where(o => o.Id == (long)id).First(); var persons = visitingFile.Connectors.Where(o => o.RelationType == SharedClass.GetRelationType(relation)).ToList(); if (persons.Count() != 0) { return persons.First().BSI__Clinic_Employees.First_Name + " " + persons.First().BSI__Clinic_Employees.Last_Name; } else { return nobody; } } }
public static void CreateConnectorObject( Medical_Clinic_Entities mc, string Employee, int? Service, int? EmployeeService, Guid Petient, long? File, long? Financial, SharedClass.RelationType RelationType ) { var connector = new Connector(); connector.EmployeeId = Employee; connector.ServiceId = Service; connector.EmployeeServiceId = EmployeeService; connector.PetientId = Petient; connector.FileId = File; connector.FinancialId = Financial; connector.RelationType = SharedClass.GetRelationType(RelationType); connector.CreatedDate = DateTime.Now; mc.Connectors.Add(connector); }
public static void CreateConnectorObject( Medical_Clinic_Entities mc, string Employee, List<int> Parts, Guid Petient, long? File, long? Financial, SharedClass.RelationType RelationType ) { foreach (var part in Parts) { ModelClass.CreateConnectorObject( mc, Employee, part, mc.BSI__Employee_Service_Set.Where(o => o.Employee_Id == Employee && o.Service_Id == part).First().Id, Petient, File, Financial, RelationType ); } }
public static void RemoveConnectorObjectUsingFinancialId( long? Financial, SharedClass.RelationType RelationType ) { using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities()) { string relation = SharedClass.GetRelationType(RelationType); var connectorToRemove = mc.Connectors.Where(o => o.FinancialId == Financial && o.RelationType == relation).ToList(); if (connectorToRemove.Count() != 0) { mc.Connectors.RemoveRange(connectorToRemove); mc.SaveChanges(); } } }
private bool isTimeValidForAllocation(DateTime start, DateTime end, SharedClass.RelationType relation, string employeeId) { using (Medical_Clinic_Entities mc = new Medical_Clinic_Entities()) { var allTheDayFinancialFiles = mc.Petient_Visiting_Financials.Where(o => (start <= o.TimeVisitStarts && o.TimeVisitStarts < end) || (start < o.TimeVisitEnds && o.TimeVisitEnds <= end) || (o.TimeVisitStarts <= start && end <= o.TimeVisitEnds) ).ToList(); if (allTheDayFinancialFiles.Count() != 0) { foreach (var financialFile in allTheDayFinancialFiles) { string employeeRelation = SharedClass.GetRelationType(relation); if (financialFile.Connectors.Where(o => o.EmployeeId == employeeId && o.RelationType == employeeRelation).Count() != 0) { //Cannot Allocate Time For Employee! return false; } } } return true; } }