public ActionResult UseTemplate(int?Id)
        {
            Models.HisProfileReq hisProfileReq = (HisProfileReq)Session["CreateRequestHdr"];

            // TO-DO: add template details to profile requests
            List <HisProfileReq> requestList = new List <HisProfileReq>();

            //get details of the selected template
            List <HisTemplateReqItem> template = db.HisTemplateReqItems.Where(t => t.HisTemplateRequestId == (int)Id).ToList();

            foreach (var tempDetails in template)
            {
                requestList.Add(new HisProfileReq()
                {
                    HisProfileId   = hisProfileReq.HisProfileId,
                    HisRequestId   = tempDetails.HisRequestId,
                    dtRequested    = hisProfileReq.dtRequested,
                    dtSchedule     = DateTime.Parse(hisProfileReq.dtSchedule.ToString()).AddDays((int)tempDetails.RefDay),
                    dtPerformed    = hisProfileReq.dtPerformed,
                    Remarks        = tempDetails.Remarks,
                    HisPhysicianId = hisProfileReq.HisPhysicianId,
                    HisInchargeId  = hisProfileReq.HisInchargeId
                });
            }

            db.HisProfileReqs.AddRange(requestList);
            db.SaveChanges();

            Console.WriteLine("HELLO");


            return(RedirectToAction("Index", new { RptType = 6, status = 1 }));
        }
Пример #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));
        }