// GET: ServicePayments/Create
        public ActionResult Create(int? id)
        {
            ServicePaymentViewModel model = new ServicePaymentViewModel();
            model.ServicePaymentList = new List<ServicePayment>();
            var appointment = db.Appointments.Include(a => a.PatientDetail).Where(a => a.ID == id).OrderByDescending(a =>a.AppointmentDate).FirstOrDefault();
            ServicePayment servicePayment = new ServicePayment();
            servicePayment.Appointment = appointment;
            servicePayment.ServiceUnit = 1;
            servicePayment.Appointment_ID = appointment.ID;
            model.ServicePayment = servicePayment;
            model.ServicePayment.PaymentModeID = 0;
            ViewBag.ServicePayment_Doctor_ID = new SelectList(db.Doctors.Include(s => s.EmployeeDetail), "ID", "EmployeeDetail.FirstName");
            ViewBag.ServicePayment_Service_ID = new SelectList(db.Services, "ID", "Name");
            ViewBag.ServicePayment_ServiceSubCategory_ID = new SelectList(db.ServiceSubCategories, "ID", "Name");
            ViewBag.ServicePayment_PaymentModeID = new SelectList(db.PaymentModes, "ID", "Mode");

            return View(model);
        }
        public ActionResult Edit(ServicePayment servicePayment)
        {
            if (ModelState.IsValid)
            {
                var currentUserId = User.Identity.GetUserId();
                long customerId = 1;

                if (currentUserId != null)
                {
                    var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    customerId = manager.FindById(currentUserId).HMSEmpID;
                }
                servicePayment.UpdatedDate = DateTime.Now;
                servicePayment.UpdatedBy = customerId;
                db.Entry(servicePayment).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            List<DoctorName> doctornamelist = UtilityManager.GetRadiologyDoctor();
            ViewBag.Doctor_ID = new SelectList(doctornamelist, "ID", "Name", servicePayment.Doctor_ID);
            //ViewBag.PatientStatus_ID = new SelectList(db.PatientStatus, "ID", "ID", servicePayment.PatientStatus_ID);
            ViewBag.Service_ID = new SelectList(db.Services, "ID", "Name", servicePayment.Service_ID);
            ViewBag.ServiceSubCategory_ID = new SelectList(db.ServiceSubCategories, "ID", "Name", servicePayment.ServiceSubCategory_ID);
            ViewBag.PaymentModeID = new SelectList(db.PaymentModes, "ID", "Mode", servicePayment.PaymentModeID);
            return View(servicePayment);
        }