Exemplo n.º 1
0
        // GET: DashBoard/DashBoard
        public ActionResult Index()
        {
            ViewBag.menu = "inicio";

            SessionInitialize();

            LocationCAD        cadPos        = new LocationCAD();
            LocationCEN        cen           = new LocationCEN(cadPos);
            IList <LocationEN> listLocations = cen.ReadAll(0, -1);

            ViewBag.numLocations = listLocations.Count;

            PractitionerCAD        cadPrac           = new PractitionerCAD();
            PractitionerCEN        cenPrac           = new PractitionerCEN(cadPrac);
            IList <PractitionerEN> listPracticioners = cenPrac.ReadAll(0, -1);

            ViewBag.numPractitioners = listPracticioners.Count;

            PatientCAD        cadPatient   = new PatientCAD();
            PatientCEN        cenPatient   = new PatientCEN(cadPatient);
            IList <PatientEN> listPatients = cenPatient.ReadAll(0, -1);

            ViewBag.numPatients = listPatients.Count;

            MedicationCAD        cadMedication   = new MedicationCAD();
            MedicationCEN        cenMedication   = new MedicationCEN(cadMedication);
            IList <MedicationEN> listMedications = cenMedication.ReadAll(0, -1);

            ViewBag.numMedications = listMedications.Count;

            CarePlanCAD        cadCarePlan   = new CarePlanCAD();
            CarePlanCEN        cenCarePlan   = new CarePlanCEN(cadCarePlan);
            IList <CarePlanEN> listCarePlans = cenCarePlan.ReadAll(0, -1);

            ViewBag.numCarePlans = listCarePlans.Count;

            GoalCAD        cadGoal   = new GoalCAD();
            GoalCEN        cenGoal   = new GoalCEN(cadGoal);
            IList <GoalEN> listGoals = cenGoal.ReadAll(0, -1);

            ViewBag.numGoals = listGoals.Count;

            SpecialtyCAD        cadSpecialty   = new SpecialtyCAD();
            SpecialtyCEN        cenSpecialty   = new SpecialtyCEN(cadSpecialty);
            IList <SpecialtyEN> listSpecialtys = cenSpecialty.ReadAll(0, -1);

            ViewBag.numSpecialtys = listSpecialtys.Count;

            EncounterCAD        cadEncounter   = new EncounterCAD();
            EncounterCEN        cenEncounter   = new EncounterCEN(cadEncounter);
            IList <EncounterEN> listEncounters = cenEncounter.ReadAll(0, -1);

            ViewBag.numEncounters = listEncounters.Count;

            SessionClose();

            return(View("~/Areas/DashBoard/Views/Home/DashBoard.cshtml"));
        }
Exemplo n.º 2
0
        public HttpResponseMessage ReadAll()
        {
            // CAD, CEN, EN, returnValue
            CarePlanRESTCAD carePlanRESTCAD = null;
            CarePlanCEN     carePlanCEN     = null;

            List <CarePlanEN>   carePlanEN  = null;
            List <CarePlanDTOA> returnValue = null;

            try
            {
                SessionInitializeWithoutTransaction();


                carePlanRESTCAD = new CarePlanRESTCAD(session);
                carePlanCEN     = new CarePlanCEN(carePlanRESTCAD);

                // Data
                // TODO: paginación

                carePlanEN = carePlanCEN.ReadAll(0, -1).ToList();

                // Convert return
                if (carePlanEN != null)
                {
                    returnValue = new List <CarePlanDTOA>();
                    foreach (CarePlanEN entry in carePlanEN)
                    {
                        returnValue.Add(CarePlanAssembler.Convert(entry, session));
                    }
                }
            }

            catch (Exception e)
            {
                if (e.GetType() == typeof(HttpResponseException))
                {
                    throw e;
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto"))
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden);
                }
                else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
            finally
            {
                SessionClose();
            }

            // Return 204 - Empty
            if (returnValue == null || returnValue.Count == 0)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NoContent));
            }
            // Return 200 - OK
            else
            {
                return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue));
            }
        }