Ejemplo n.º 1
0
        public OrderModel ReadOrderById(long id, string lang)
        {
            string query = $@"
                select o.IdOrder, o.IdPatient, o.IdEmployee, e.FirstName as DoctorFirstName, e.Surname as DoctorSurname, o.IdWard, wt.Name as Ward, o.Institution,
                    o.Comment, o.DateOfOrder, o.DateOfReceived, o.IdStatus, st.Name as Status, o.IdPriority, prt.Name as Priority, p.FirstName, p.Surname, p.IdCardNumber
                from Orders o
                join Patients p on o.IdPatient = p.IdPatient
                join Employees e on o.IdEmployee = e.IdEmployee
                join Priorities pr  on o.IdPriority = pr.IdPriority
                join PriorityTranslations prt on pr.IdPriority = prt.IdPriority
                left join Wards w on o.IdWard = w.IdWard
                full join WardTranslations wt on w.IdWard = wt.Idward
                join Status s on o.IdStatus = s.IdStatus
                join StatusTranslations st on s.IdStatus = st.IdStatus
                where (w.IdWard is null or wt.IdLanguage = (select l1.IdLanguage from Languages l1 where l1.Code = '{lang}'))
                    and st.IdLanguage = (select l2.IdLanguage from Languages l2 where l2.Code = '{lang}') 
                    and prt.IdLanguage = (select l3.IdLanguage from Languages l3 where l3.Code = '{lang}')
                    and IdOrder = {id}
            ";

            return(BaseDAO.SelectFirst(query, ReadOrderModel));
        }