Ejemplo n.º 1
0
        public ActionResult BillCalculation(BillViewModel model)
        {
            BillResponseModel Result = new BillResponseModel();

            if (ModelState.IsValid)
            {
                Result = _bill.FindtheBilledAmount(model);
            }
            return(Json(new { Result = Result }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetPatientWithBill()
        {
            var patients = GetPatientDtosWithBill();

            var resposeModel = new BillResponseModel {
                Patients = patients
            };

            if (resposeModel != null)
            {
                return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, resposeModel)));
            }
            else
            {
                return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No patients found", "Please register a patient"))));
            }
        }
        public BillResponseModel FindtheBilledAmount(BillViewModel Model)
        {
            BillResponseModel Result = new BillResponseModel();

            Model.TotalPrice = Model.AmountPerPerson * Model.NumberofCustomers;
            try
            {
                if (Model.PromoCode == Constants.NonePromoCode || string.IsNullOrEmpty(Model.PromoCode))
                {
                    using (WOLFCOMTechnicalTestEntities db = new WOLFCOMTechnicalTestEntities())
                    {
                        var WithoutPromoCodeList = db.PromoCodeDetails.Where(x => (x.CanAvailWithoutPromoCode == true) && (x.Status == true)).ToList();

                        if (WithoutPromoCodeList.Count() == 0)
                        {
                            return(new BillResponseModel(Model.TotalPrice));
                        }

                        Result = BillCalculation.ExecuteBillCalculation(WithoutPromoCodeList, Model);
                    }
                }
                else
                {
                    using (WOLFCOMTechnicalTestEntities db = new WOLFCOMTechnicalTestEntities())
                    {
                        var WithPromoCodeList = db.PromoCodeDetails.Where(x => (x.CanAvailWithoutPromoCode == true || x.PromoCode == Model.PromoCode) && (x.Status == true)).ToList();
                        if (WithPromoCodeList.Count() == 0)
                        {
                            return(new BillResponseModel(Model.TotalPrice));
                        }

                        Result = BillCalculation.ExecuteBillCalculation(WithPromoCodeList, Model);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("This is an error message" + ex);
                return(null);
            }
            return(Result);
        }