//create assigned tasks
        public void createAssignedTask(string taskName, string username)
        {
            using (var db = new HealthModelsDataContext())
            {
                Task task = db.Tasks.SingleOrDefault(targetTask => targetTask.taskName.Equals(taskName));
                User user = db.Users.SingleOrDefault(targetUser => targetUser.userName.Equals(username));

                if (task != null && user != null)
                {
                    var assignedTask = new AssignedTask();

                    assignedTask.taskId = task.id;
                    assignedTask.userId = user.id;

                    db.AssignedTasks.InsertOnSubmit(assignedTask);
                    db.SubmitChanges();
                }
            }
        }
Example #2
0
        //create alarm attendance
        public void createAlarmAttendance(string alarmName, string userName)
        {
            using (var db = new HealthModelsDataContext())
            {
                Alarm alarm = db.Alarms.SingleOrDefault(targetAlarm => targetAlarm.name.Equals(alarmName));
                User  user  = db.Users.SingleOrDefault(targetUser => targetUser.userName.Equals(userName));

                if (alarm != null && user != null)
                {
                    var alarmAttendace = new AlarmAttendance();

                    alarmAttendace.userId  = user.id;
                    alarmAttendace.alarmId = alarm.id;

                    db.AlarmAttendances.InsertOnSubmit(alarmAttendace);
                    db.SubmitChanges();
                }
            }
        }
Example #3
0
        //delete alarm attendance
        public void deleteAlarmAttendance(string alarmName, string userName)
        {
            using (var db = new HealthModelsDataContext())
            {
                Alarm alarm = db.Alarms.SingleOrDefault(targetAlarm => targetAlarm.name.Equals(alarmName));
                User  user  = db.Users.SingleOrDefault(targetUser => targetUser.userName.Equals(userName));

                if (alarm != null && user != null)
                {
                    AlarmAttendance alarmAttendace = db.AlarmAttendances.SingleOrDefault(attendance => attendance.alarmId == alarm.id && attendance.userId == user.id);

                    if (alarmAttendace != null)
                    {
                        db.AlarmAttendances.DeleteOnSubmit(alarmAttendace);
                        db.SubmitChanges();
                    }
                }
            }
        }
        public void updateAlarmPublisher(int id, string pacientName, string condition, string location, string password)
        {
            var publisher = new AlarmPublisher();

            using (var db = new HealthModelsDataContext())
            {
                publisher = db.AlarmPublishers.SingleOrDefault(targetPublisher => targetPublisher.id == id);

                if (publisher != null)
                {
                    publisher.pacient_name = pacientName;
                    publisher.condition    = condition;
                    publisher.location     = location;
                    publisher.password     = password;

                    db.SubmitChanges();
                }
            }
        }
Example #5
0
        //update Alarm
        public void updateAlarm(string name, string type, string location, string status)
        {
            var alarm = new Alarm();

            using (var db = new HealthModelsDataContext())
            {
                alarm = db.Alarms.SingleOrDefault(targetAlarm => targetAlarm.name.Equals(name));

                if (alarm != null)
                {
                    alarm.name     = name;
                    alarm.type     = type;
                    alarm.time     = DateTime.Now;
                    alarm.location = location;
                    alarm.status   = status;

                    db.SubmitChanges();
                }
            }
        }