public ActionResult Create(LabPaymentViewModel 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 (LabPayment item in model.LabPayments)
                {
                    item.CreatedDate = DateTime.Now;
                    item.UpdatedDate = DateTime.Now;
                    item.CreatedBy = Convert.ToInt32(customerId);
                    item.UpdatedBy = Convert.ToInt32(customerId);
                    item.PaymentModeID = item.PaymentModeID;
                    if (item.DueAmount == 0)
                    {
                        item.PaymentStatusID = 1;
                    }
                    else
                    {
                        item.PaymentStatusID = 3;
                    }
                    db.LabPayments.Add(item);
                }
                try
                {
                    db.SaveChanges();
                    return RedirectToAction("Index");
                    //return RedirectToAction("Service", "Transaction");
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }

            List<DoctorName> doctornamelist = UtilityManager.GetLabDoctor();
            ViewBag.LabPayment_Doctor_ID = new SelectList(doctornamelist, "ID", "Name", model.LabPayment.Doctor_ID);
            ViewBag.Appointment_ID = new SelectList(db.Appointments, "ID", "ReferalDetails", model.LabPayment.Appointment_ID);
            ViewBag.LabCategory_ID = new SelectList(db.LabCategories, "ID", "Name", model.LabPayment.LabCategory_ID);
            ViewBag.LabTest_ID = new SelectList(db.LabTests, "ID", "Name", model.LabPayment.LabTest_ID);
            ViewBag.LabPayment_PaymentModeID = new SelectList(db.PaymentModes, "ID", "Mode", model.LabPayment.PaymentModeID);
            return View(model);
        }
 public ActionResult Create(int ? id)
 {
     LabPaymentViewModel model = new LabPaymentViewModel();
     List<LabPayment> labPaymentList = new List<LabPayment>();
     var appointment = db.Appointments.Include(l => l.PatientDetail).Where(a => a.ID == id).FirstOrDefault();
     LabPayment labPayment = new LabPayment();
     labPayment.Appointment = appointment;
     labPayment.Appointment_ID = appointment.ID;
     labPayment.Quantity = 1;
     model.LabPayment = labPayment;
     ViewBag.LabPayment_Doctor_ID = new SelectList(db.Doctors.Include(s => s.EmployeeDetail), "ID", "EmployeeDetail.FirstName");
     ViewBag.LabPayment_LabCategory_ID = new SelectList(db.LabCategories, "ID", "Name");
     ViewBag.LabPayment_LabTest_ID = new SelectList(db.LabTests, "ID", "Name");
     ViewBag.LabPayment_PaymentModeID = new SelectList(db.PaymentModes, "ID", "Mode");
     return View(model);
 }
 public ActionResult Create(int? id)
 {
     LabPaymentViewModel model = new LabPaymentViewModel();
     List<LabPayment> labPaymentList = new List<LabPayment>();
     var appointment = db.Appointments.Include(l => l.PatientDetail).Where(a => a.ID == id).FirstOrDefault();
     LabPayment labPayment = new LabPayment();
     labPayment.Appointment = appointment;
     labPayment.Appointment_ID = appointment.ID;
     labPayment.Quantity = 1;
     model.LabPayment = labPayment;
     List<DoctorName> doctornamelist = UtilityManager.GetLabDoctor();
     ViewBag.LabPayment_Doctor_ID = new SelectList(doctornamelist, "ID", "Name");
     ViewBag.LabPayment_LabCategory_ID = new SelectList(db.LabCategories, "ID", "Name");
     ViewBag.LabPayment_LabTest_ID = new SelectList(db.LabTests, "ID", "Name");
     ViewBag.LabPayment_PaymentModeID = new SelectList(db.PaymentModes, "ID", "Mode", 1);
     return View(model);
 }