Exemplo n.º 1
0
        /// <summary>
        /// Add an item to the patient's invoice.
        /// </summary>
        /// <returns>The Jason object so it can be immediately displayed.</returns>
        public JsonResult AddInvoiceItem()
        {
            try
            {
                //Build Line Item objects
                InvoiceItem lineItem = new InvoiceItem();

                //Get patient object
                int patientID = int.Parse(Request.Form["patientID"]);
                PatientRepository patientRepo = new PatientRepository();
                var patient = patientRepo.Get(patientID);

                //Get current open patient checkin
                var query = from checkin in patient.PatientCheckIns
                            where checkin.CheckOutTime == DateTime.MinValue
                            select checkin;
                PatientCheckIn openCheckIn = query.First<PatientCheckIn>();

                //Invoice Repository
                InvoiceRepository invoiceRepo = new InvoiceRepository();

                //Product Repository
                ProductRepository productRepo = new ProductRepository();

                //Service Repository
                ServiceRepository serviceRepo = new ServiceRepository();

                //Quantity
                if (Request.Form["quantity"] != "")
                {
                    lineItem.Quantity = int.Parse(Request.Form["quantity"]);
                    lineItem.Invoice = openCheckIn.Invoice;
                    lineItem.IsActive = true;

                    //Product
                    if (Request.Form["product"] != "")
                    {
                        lineItem.Product = productRepo.Get(int.Parse(Request.Form["product"]));
                        lineItem.Service = null;
                        invoiceRepo.AddLineItem(lineItem);
                        UnitOfWork.CurrentSession.Flush();
                        return Json(new
                        {
                            error = "false",
                            lineItem.Product.Name,
                            lineItem.Quantity

                        });
                    } //Service
                    else if (Request.Form["service"] != "")
                    {
                        lineItem.Service = serviceRepo.Get(int.Parse(Request.Form["service"]));
                        lineItem.Product = null;
                        invoiceRepo.AddLineItem(lineItem);
                        UnitOfWork.CurrentSession.Flush();
                        return Json(new
                        {
                            error = "false",
                            lineItem.Service.Name,
                            lineItem.Quantity
                        });
                    }
                }

                return Json(new
                {
                    error = "false"
                });
            }
            catch (Exception e)
            {
                return Json(new
                {
                    error = "true",
                    status = e.Message
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generate a list of services
        /// </summary>
        /// <returns></returns>
        public JsonResult ServiceList()
        {
            try
            {
                int serviceID = int.Parse(Request.Form["ID"]);
                ServiceRepository serviceRepo = new ServiceRepository();
                var service = serviceRepo.Get(serviceID);

                var resultSet = new List<object>();
                var jsonResult = new JsonResult();

                resultSet.Add(new
                {
                    error = false,
                    Price = service.Price
                });

                jsonResult.Data = resultSet;

                return jsonResult;
            }
            catch (Exception)
            {

                return Json(new
                {
                    error = true
                });
            }
        }
Exemplo n.º 3
0
        public JsonResult DeleteService()
        {
            try
            {
                ServiceRepository serviceRepo = new ServiceRepository();
                Service service = serviceRepo.Get(int.Parse(Request.Form["Service"]));
                service.IsActive = false;

                return Json(new
                {
                    error = false
                });
            }
            catch
            {
                return Json(new
                {
                    error = true
                });
            }
        }
Exemplo n.º 4
0
        public JsonResult EditService()
        {
            try
            {
                ServiceRepository serviceRepo = new ServiceRepository();
                Service service = serviceRepo.Get(int.Parse(Request.Form["Service"]));
                service.Price = decimal.Parse(Request.Form["Cost"]);

                return Json(new
                {
                    error = false
                });
            }
            catch
            {
                return Json(new
                {
                    error = true
                });
            }
        }
Exemplo n.º 5
0
        public JsonResult AddService()
        {
            try
            {
                ServiceRepository serviceRepo = new ServiceRepository();

                Service service = new Service();
                service.IsActive = true;
                service.Name = Request.Form["Name"];
                service.Price = decimal.Parse(Request.Form["Cost"]);

                serviceRepo.Add(service);

                return Json(new
                {
                    error = false,
                    Name = service.Name,
                    Id = service.Id
                });
            }
            catch
            {
                return Json(new
                {
                    error = true
                });
            }
        }