Exemplo n.º 1
0
        public ActionResult Index()
        {
            var userId = (long)Session[Models.Login.UserIdSession];

            var patient = DatabasePatientService.GetByUserId(userId);

            if (patient == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            patient.LoadUserData();

            return(View("Index", Tuple.Create(patient, true)));
        }
Exemplo n.º 2
0
        public ActionResult Index(string contactMethod, string notificationTime, string birthdayEnabled, string refillsEnabled)
        {
            var userId  = (long)Session[Models.Login.UserIdSession];
            var patient = DatabasePatientService.GetByUserId(userId);

            if (patient == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            patient.LoadUserData();

            SavePatient(patient, contactMethod, notificationTime, birthdayEnabled, refillsEnabled);
            return(View("Index", Tuple.Create(patient, true)));
        }
        public static User GetFullById(long user_id)
        {
            using (var db = DatabaseService.Connection) {
                Dapper.SqlMapper.SetTypeMap(typeof(User), new ColumnAttributeTypeMapper <User>());
                var u = db.Query <User>(ScriptService.Scripts["user_getbyid"], new { user_id = user_id }).FirstOrDefault();

                switch (u.Type)
                {
                case User.UserType.Pharmacist: {
                    var hu = DatabasePharmacistService.GetByUserId(u.UserId);
                    hu.LoadUserData();
                    return(hu);
                }

                case User.UserType.Patient: {
                    var hu = DatabasePatientService.GetByUserId(u.UserId);
                    hu.LoadUserData();
                    return(hu);
                }
                }
                return(u);
            }
        }