예제 #1
0
        public async Task <ActionResult> delapp(IEnumerable <int> Id)//delete appointments
        {
            if (Id != null)
            {
                if (Id.Count() > 0)
                {
                    foreach (var id in Id)
                    {
                        try
                        {
                            AppBookingTb b = db.AppBookingTb.First(r => r.id == id);
                            db.AppBookingTb.Remove(b);
                            await db.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            return(Json("error occured" + ex, JsonRequestBehavior.AllowGet));

                            throw ex;
                        }
                    }
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public async Task <ActionResult> pendapp(IEnumerable <int> Id)//mark appointments has pending
        {
            string approverId     = Session["Id"].ToString();
            var    approverDetail = db.Users.Find(approverId);

            if (Id != null)
            {
                if (Id.Count() > 0)
                {
                    foreach (var id in Id)
                    {
                        try
                        {
                            AppBookingTb b = db.AppBookingTb.First(r => r.id == id);
                            b.ApprovedStatus = "pending";
                            b.notifyStatus   = 1;
                            b.ApprovedBy     = approverDetail.FullName;
                            await db.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            return(Json("error occured" + ex, JsonRequestBehavior.AllowGet));

                            throw ex;
                        }
                    }
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public async Task <ActionResult> ApproveAppointment(int ids, FormCollection f)
        {
            string       approverId     = Session["Id"].ToString();
            var          approverDetail = db.Users.Find(approverId);
            string       body;
            AppBookingTb app = await db.AppBookingTb.FindAsync(ids);

            app.ApprovedStatus = "approved";
            app.notifyStatus   = 1;
            app.ApproveDate    = DateTime.UtcNow;
            app.ApprovedBy     = approverDetail.FullName;
            if (!string.IsNullOrEmpty(f["appdate"]))
            {
                string appdate = f["appdate"];
                app.RescheduledDate = DateTime.ParseExact(appdate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            await db.SaveChangesAsync();

            if (!string.IsNullOrEmpty(f["Message"]))
            {
                body = f["Message"];
            }
            else
            {
                body = "<p>We want to inform you that your appointment request with a one of our "
                       + "health professional has been approved.<br/> Date and time will be communicated" +
                       " to you shortly. <br/> Thanks for choosing iHealth Nigeria GSFM. </br></br>Best Regards</br></br>iHealth Nigeria GSFM Team.</p>";
            }
            await em.appointmentBookingApproval(app.Name, "Appointment Approved", app.Email, body);

            TempData["success"] = "Appointment has been approved successfully";
            return(RedirectToAction("newapp"));
        }
예제 #4
0
        public async Task <ActionResult> bookapp(appBooking_ViewModel model, FormCollection f)
        {
            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(f["appwith"]))
                {
                    Random       rd    = new Random();
                    int          rdn   = rd.Next(9999999);
                    AppBookingTb appbk = new AppBookingTb();
                    appbk.Name             = model.Name;
                    appbk.app_id           = rdn;
                    appbk.Email            = model.Email;
                    appbk.Phone            = model.Phone;
                    appbk.Message          = model.Message;
                    appbk.Appointment_With = f["appwith"];
                    string appdate = f["appdate"];
                    appbk.state            = f["state"];
                    appbk.city             = f["city"];
                    appbk.notifyStatus     = 0;
                    appbk.Appointment_Date = DateTime.ParseExact(appdate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    db.AppBookingTb.Add(appbk);
                    await db.SaveChangesAsync();

                    //TODO: send appointment information to both admin and  appnt requestor via email.
                    string body = "<p>Your request to have an appointment with a " + appbk.Appointment_With + "" +
                                  " has been received and you will be communicated once approved." +
                                  "<br/>Thank you for choosing iHealth Nigeria GSFM. <br/></br> Best Regards, <br/></br> iHealth Nigeria GSFM Team.</p>";
                    await em.appointmentBookingNotification(model.Name, body, "Appointment Received", model.Email);

                    TempData["success"] = "Appointment has been created successfully!";
                    return(View("Index"));
                }
                {
                    ModelState.AddModelError("", "Select who you want to have appointment with.");
                    return(View("Index"));
                }
            }
            else
            {
                ModelState.AddModelError("", "All field mark with (*) be fill.");
                return(View("Index"));
            }
        }