// GET: HIS10/HisNotificationLogs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            HisNotificationLog hisNotificationLog = db.HisNotificationLogs.Find(id);

            if (hisNotificationLog == null)
            {
                return(HttpNotFound());
            }
            HisNotificationRecipient recipient = db.HisNotificationRecipients.Where(s => s.HisNotificationId == id).FirstOrDefault();

            ViewBag.getNotificationLogs = db.HisNotificationLogs.Where(s => s.HisNotificationRecipientId == recipient.Id).ToList();


            HisNotificationRecipient Recipients = db.HisNotificationRecipients.Where(s => s.HisNotificationId == id).FirstOrDefault();

            //ViewBag.getNotificationLogs = db.HisNotificationLogs.Where();

            ViewBag.getNotificationLogs = db.HisNotificationLogs.Where(s => s.HisNotificationRecipient.HisNotification.Id == id).First();

            return(View(hisNotificationLog));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "Id,RecType,Recipient,Message,DtSending,RefId,RefTable")] HisNotification hisNotification)
        {
            if (ModelState.IsValid)
            {
                db.HisNotifications.Add(hisNotification);

                Models.HisProfileReq request = db.HisProfileReqs.Find(hisNotification.RefId);
                request.dtRequested = DateTime.Now;
                request.dtSchedule  = hisNotification.DtSending;

                //create contact lists

                HisNotificationRecipient recipient = new HisNotificationRecipient();
                recipient.HisNotificationId = hisNotification.Id;

                //get contact number of physician
                HisPhysician physician        = db.HisPhysicians.Where(s => s.Id == request.HisPhysicianId).FirstOrDefault();
                var          notify_Physician = new HisNotificationRecipient //Make sure you have a table called test in DB
                {
                    HisNotificationId = hisNotification.Id,
                    ContactInfo       = physician.ContactInfo
                };

                //get contact number of incharge
                HisIncharge incharge = db.HisIncharges.Where(s => s.Id == request.HisInchargeId).FirstOrDefault();
                HisNotificationRecipient notify_inchage = new HisNotificationRecipient
                {
                    HisNotificationId = hisNotification.Id,
                    ContactInfo       = incharge.ContactInfo
                };

                //get contact info of client (hisprofile)
                HisProfile client = db.HisProfiles.Where(s => s.Id == request.HisProfileId).FirstOrDefault();
                HisNotificationRecipient notify_client = new HisNotificationRecipient
                {
                    HisNotificationId = hisNotification.Id,
                    ContactInfo       = client.ContactInfo
                };

                //add to database
                db.HisNotificationRecipients.Add(notify_Physician);
                db.HisNotificationRecipients.Add(notify_inchage);
                db.HisNotificationRecipients.Add(notify_client);
                db.SaveChanges();

                //HIS10/HisProfileReqs?RptType=1&status=0
                // return RedirectToAction("Details", "HisNotifications", new { id = hisNotification.Id });

                View(hisNotification);
            }

            return(View(hisNotification));
        }