public void Add(Visit visit) { try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { db.Visit.Add(visit); db.SaveChanges(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } }
public void Add(Employee employee) { try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { db.Employee.Add(employee); db.SaveChanges(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } }
public void Remove(long id) { try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { Visit_type visit_type = db.Visit_type.Find(id); visit_type.is_removed = true; db.SaveChanges(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } }
public bool Check_if_removed(long id) { bool is_removed = true; try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { is_removed = db.Visit_type.Find(id).is_removed; } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(is_removed); }
public Visit Get_by_id(long id) { Visit visit = new Visit(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { visit = db.Visit.Find(id); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(visit); }
public Employee Get_by_id(long id) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee.Find(id); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(employee); }
public Employee Get_by_guid(string guid) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee.Where(a => a.guid == guid).FirstOrDefault(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(employee); }
public List <Visit_type> Get_all() { List <Visit_type> list_of_visit_types = new List <Visit_type>(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { list_of_visit_types = db.Visit_type.ToList(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(list_of_visit_types); }
public List <Visit_type> Get_all_not_removed() { List <Visit_type> list_of_visit_types = new List <Visit_type>(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { list_of_visit_types = db.Visit_type .Where(a => a.is_removed == false) .ToList(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(list_of_visit_types); }
public Employee Add_guid(long id) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee.Find(id); employee.guid = Guid.NewGuid().ToString(); db.SaveChanges(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(employee); }
public List <Employee> Get_all_except_admin() { List <Employee> list_of_employees = new List <Employee>(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { list_of_employees = db.Employee .Where(a => a.is_removed == false && a.id != 1) .ToList(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(list_of_employees); }
public Employee Get_by_login(string login) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee.Where(a => a.is_removed == false && (a.name.ToLower() + "." + a.surname.ToLower()) == login) .FirstOrDefault(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(employee); }
public List <Visit_type> Get_all_except_first() { List <Visit_type> list_of_visit_types = new List <Visit_type>(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { list_of_visit_types = db.Visit_type .Where(a => a.is_removed == false && a.id != 1) // id=1 it is 'Other' which cannot edit .ToList(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(list_of_visit_types); }
public Visit_type Get_by_name(string name) { Visit_type visit_type = new Visit_type(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { visit_type = db.Visit_type .Where(a => a.is_removed == false && a.name == name) .FirstOrDefault(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(visit_type); }
public void Update(Visit_type visit_type) { try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { Visit_type visit_type_from_db = db.Visit_type.Find(visit_type.id); if (visit_type_from_db != null) { visit_type_from_db.name = visit_type.name; db.SaveChanges(); } } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } }
public List <Visit> Get_list_by_date(DateTime date) { List <Visit> list_of_visits = new List <Visit>(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { list_of_visits = db.Visit.Where(a => a.start_time.Day == date.Day && a.start_time.Month == date.Month && a.start_time.Year == date.Year && a.is_removed == false) .ToList(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(list_of_visits); }
public void Update_password(long id, string password) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee.Find(id); if (employee != null) { employee.password = password; db.SaveChanges(); } } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } }
public Employee Get_by_name_surname(string name, string surname) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee .Where(a => a.is_removed == false && a.name == name && a.surname == surname) .FirstOrDefault(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(employee); }
public Employee Get_by_id_and_password(long id, string password) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee .Where(a => a.is_removed == false && a.id == id && a.password == password) .FirstOrDefault(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(employee); }
public void Update(Employee employee_to_edit) { Employee employee = new Employee(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { employee = db.Employee.Find(employee_to_edit.id); if (employee != null) { employee.name = employee_to_edit.name; employee.surname = employee_to_edit.surname; db.SaveChanges(); } } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } }
public List <Visit> Get_list_to_bottom_charts(DateTime start_range_date, DateTime end_range_date) { List <Visit> list_of_visits = new List <Visit>(); try { using (Visit_manager_dbEntities db = new Visit_manager_dbEntities()) { list_of_visits = db.Visit.Where(a => a.is_removed == false && a.Employee.is_removed == false && a.employee_id != 1 && a.start_time >= start_range_date && a.start_time <= end_range_date) .ToList(); } } catch (Exception ex) { NLog_logger.Loger.Error(ex); } return(list_of_visits); }