public ActionResult Create(ServicePaymentViewModel model)
        {
            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;
                }

                foreach(ServicePayment item in model.ServicePaymentList)
                {
                    item.CreatedDate = DateTime.Now;
                    item.UpdatedDate = DateTime.Now;
                    item.CreatedBy = Convert.ToInt32(customerId);
                    item.UpdatedBy = Convert.ToInt32(customerId);
                    db.ServicePayments.Add(item);
                }

                db.SaveChanges();
                return RedirectToAction("Index", "ServicePayments");
            }

            ViewBag.ServicePayment_Doctor_ID = new SelectList(db.Doctors, "ID", "OtherDetails", model.ServicePayment.Doctor_ID);
            //ViewBag.PatientStatus_ID = new SelectList(db.PatientStatus, "ID", "ID", servicePayment.PatientStatus_ID);
            ViewBag.ServicePayment_Service_ID = new SelectList(db.Services, "ID", "Name", model.ServicePayment.Service_ID);
            ViewBag.ServicePayment_ServiceSubCategory_ID = new SelectList(db.ServiceSubCategories, "ID", "Name", model.ServicePayment.ServiceSubCategory_ID);
            ViewBag.ServicePayment_PaymentModeID = new SelectList(db.PaymentModes, "ID", "Mode", model.ServicePayment.PaymentModeID);
            return View(model);
        }
        // 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);
        }