/// <summary>
        /// Validates this diagnostic investigation
        /// </summary>
        /// <param name="path">The path to this object as a string</param>
        /// <param name="messages">the validation messages, these may be added to within this method</param>
        public void Validate(string path, List <ValidationMessage> messages)
        {
            var vb = new ValidationBuilder(path, messages);

            if (PathologyTestResult != null && PathologyTestResult.Any())
            {
                PathologyTestResult.ForEach(pathologyTestResult => pathologyTestResult.Validate(path + ".PathologyTestResult", messages));
            }

            if (ImagingExaminationResult != null && ImagingExaminationResult.Any())
            {
                ImagingExaminationResult.ForEach(imagingExaminationResult => imagingExaminationResult.Validate(path + ".ImagingExaminationResult", messages));
            }

            if (RequestedService != null && RequestedService.Any())
            {
                RequestedService.ForEach(requestedService => requestedService.Validate(path + ".RequestedService", messages));
            }

            if (RequestedService == null && ImagingExaminationResult == null && PathologyTestResult == null && OtherTestResult == null)
            {
                vb.AddValidationMessage(vb.PathName, null, "Each instance of this Diagnostic Investigations section SHALL have at least one instance of 'PATHOLOGY TEST RESULT' OR 'IMAGING EXAMINATION RESULT' OR 'REQUESTED SERVICE OR 'OTHER TEST RESULT'");
            }

            if (OtherTestResult != null && OtherTestResult.Any())
            {
                OtherTestResult.ForEach(otherTestResult => otherTestResult.Validate(path + ".OtherTestResult", messages));
            }
        }
Esempio n. 2
0
        public ActionResult BookingConfirmationPage(BookingConfirmationModel model)
        {
            Service             service        = repository.Services.Where(p => p.ServiceId == model.ServiceId).FirstOrDefault();
            RequestedService    requested      = repository.RequestedServices.Where(p => p.RequestedServiceId == model.RequestedServiceId).FirstOrDefault();
            Payment             payment        = repository.Payments.Where(p => p.PaymentId == model.PaymentId).LastOrDefault();
            ServiceRequestModel serviceRequest = new ServiceRequestModel();

            //Logic for authorized user
            if (User.Identity.IsAuthenticated)
            {
                serviceRequest = new ServiceRequestModel {
                    Service = service, RequestedService = requested, Payment = payment, Discount = model.Discount
                };
            }
            //Logic for a unregistered user
            else
            {
                serviceRequest = new ServiceRequestModel {
                    Service = service, RequestedService = requested, Payment = payment
                };
            }
            return(View(serviceRequest));
        }
        /// <summary>
        /// Retour de la réponse structurée en XML
        /// </summary>
        /// <returns>Réponse (XML)</returns>
        public string GetResponse()
        {
            // On trace la demande
            LogResponse();
            // On va maintenant contruire la réponse
            string strData = Const.XmlHeader
                             + Xml_Response_Open_Tag
                             + Xml_Response_Duration_Open_Tag
                             + GetDuration()
                             + Xml_Response_Duration_Close_Tag;

            if (!IsError())
            {
                // Il n'y aucune erreur
                // On va renvoyer les données
                // et de ce fait ignorer les tag d'exception
                strData +=
                    Xml_Response_Value_Open_Tag
                    + Xml_POS_Open_Tag
                    + GetArgPos()
                    + Xml_POS_Close_Tag
                    + Xml_Customer_Open_Tag
                    + GetArgComcode()
                    + Xml_Customer_Close_Tag
                    + Xml_CostCenter_Open_Tag
                    + Util.Nvl(GetArgCostCenter(), string.Empty)
                    + Xml_CostCenter_Close_Tag
                    + Xml_Percode_Open_Tag
                    + GetArgPercode()
                    + Xml_Percode_Close_Tag
                    + Xml_Corporation_Open_Tag
                    + GetArgCorporation()
                    + Xml_Corporation_Close_Tag;


                if (!String.IsNullOrEmpty(GetPaymentType()) && GetPaymentType().Equals(Const.PaymentTypeStringCASH_FR))
                {
                    // Payment type CASH
                    strData +=
                        Xml_Service_Open_Tag + GetArgService() + Xml_Service_Close_Tag
                        + Xml_PaymentType_Open_Tag + GetPaymentType() + Xml_PaymentType_Close_Tag
                        + Xml_Origin_Open_Tag + string.Empty + Xml_Origin_Close_Tag;
                }
                else if (this.extendedPanInfos != null)
                {
                    // Payment type CREDIT CARD
                    // with BO Token
                    strData +=
                        Xml_Service_Open_Tag + GetArgService() + Xml_Service_Close_Tag
                        + Xml_PaymentType_Open_Tag + Const.PaymentTypeCreditCardShort + Xml_PaymentType_Close_Tag
                        + Xml_Origin_Open_Tag + string.Empty + Xml_Origin_Close_Tag;

                    strData += Xml_Card_Open_Tag
                               + Xml_CardType_Open_Tag + this.extendedPanInfos.GetCardType() + Xml_CardType_Close_Tag
                               + Xml_ShortCardType_Open_Tag + this.extendedPanInfos.GetShortCardType() + Xml_ShortCardType_Close_Tag
                               + Xml_CardToken_Open_Tag + GetArgToken() + Xml_CardToken_Close_Tag
                               + Xml_TruncatedCardNumber_Open_Tag + this.extendedPanInfos.GetTruncatedPan() + Xml_TruncatedCardNumber_Close_Tag
                               + Xml_CardNumber_Open_Tag + this.extendedPanInfos.GetPan() + Xml_CardNumber_Close_Tag
                               + Xml_FormOfPayment_Open_Tag +
                               String.Format("FP CC{0}{1}/{2}", this.extendedPanInfos.GetShortCardType(), this.extendedPanInfos.GetPan(), this.extendedPanInfos.GetShortExpirationDate().Replace("/", string.Empty))
                               + Xml_FormOfPayment_Close_Tag
                               + Xml_ExpirationDate_Open_Tag + this.extendedPanInfos.GetExpirationDate() + Xml_ExpirationDate_Close_Tag
                               + Xml_ShortExpirationDate_Open_Tag + this.extendedPanInfos.GetShortExpirationDate() + Xml_ShortExpirationDate_Close_Tag
                               + Xml_LodgedCard_Open_Tag + "0" + Xml_LodgedCard_Close_Tag
                               + Xml_MII_Open_Tag + this.extendedPanInfos.GetMII() + Xml_MII_Close_Tag
                               + Xml_MIIIssuerCategory_Open_Tag + this.extendedPanInfos.GetMIIIssuerCategory() + Xml_MIIIssuerCategory_Close_Tag
                               + Xml_MerchantFlow_Open_Tag + this.extendedPanInfos.GetMerchantFlow() + Xml_MerchantFlow_Close_Tag
                               + Xml_EnhancedFlow_Open_Tag + this.extendedPanInfos.GetEnhancedFlow() + Xml_EnhancedFlow_Close_Tag

                               + Xml_Card_Close_Tag;
                }
                else if (this.fOPanInfos != null)
                {
                    string truncatedPAN = CreditCardVerifier.TruncatePan(this.fOPanInfos.GetPAN());

                    // Payment type CREDIT CARD
                    // with FO Token
                    strData +=
                        Xml_Service_Open_Tag + GetArgService() + Xml_Service_Close_Tag
                        + Xml_PaymentType_Open_Tag + Const.PaymentTypeCreditCardShort + Xml_PaymentType_Close_Tag
                        + Xml_Origin_Open_Tag + Xml_Origin_Close_Tag;

                    strData += Xml_Card_Open_Tag
                               + Xml_CardType_Open_Tag + this.fOPanInfos.GetCardType() + Xml_CardType_Close_Tag
                               + Xml_ShortCardType_Open_Tag + this.fOPanInfos.GetShortCardType() + Xml_ShortCardType_Close_Tag
                               + Xml_CardToken_Open_Tag + GetArgToken() + Xml_CardToken_Close_Tag
                               + Xml_TruncatedCardNumber_Open_Tag + truncatedPAN + Xml_TruncatedCardNumber_Close_Tag
                               + Xml_CardNumber_Open_Tag + this.fOPanInfos.GetPAN() + Xml_CardNumber_Close_Tag
                               + Xml_FormOfPayment_Open_Tag +
                               String.Format("FP CC{0}{1}/{2}", this.fOPanInfos.GetShortCardType(), this.fOPanInfos.GetPAN(), this.fOPanInfos.GetShortExpirationDate().Replace("/", string.Empty))
                               + Xml_FormOfPayment_Close_Tag
                               + Xml_ExpirationDate_Open_Tag + this.fOPanInfos.GetExpirationDate() + Xml_ExpirationDate_Close_Tag
                               + Xml_ShortExpirationDate_Open_Tag + this.fOPanInfos.GetShortExpirationDate() + Xml_ShortExpirationDate_Close_Tag
                               + Xml_LodgedCard_Open_Tag + "0" + Xml_LodgedCard_Close_Tag
                               + Xml_MII_Open_Tag + this.fOPanInfos.GetMII() + Xml_MII_Close_Tag
                               + Xml_MIIIssuerCategory_Open_Tag + this.fOPanInfos.GetMIIIssuerCategory() + Xml_MIIIssuerCategory_Close_Tag
                               + Xml_MerchantFlow_Open_Tag + string.Empty + Xml_MerchantFlow_Close_Tag
                               + Xml_EnhancedFlow_Open_Tag + string.Empty + Xml_EnhancedFlow_Close_Tag

                               + Xml_Card_Close_Tag;
                }
                else
                {
                    // hierarchival payment means
                    RequestedService rs = this.travelerPaymentMeanResponse.GetNav_PaymentMeans().RequestedService[0];

                    strData += Xml_Service_Open_Tag + rs.Service[0] + Xml_Service_Close_Tag
                               + Xml_PaymentType_Open_Tag + rs.PaymentType + Xml_PaymentType_Close_Tag
                               + Xml_Origin_Open_Tag + rs.Origin + Xml_Origin_Close_Tag;

                    if (!String.IsNullOrEmpty(rs.PaymentType) && rs.PaymentType.Equals(Const.PaymentTypeCreditCardShort) && !String.IsNullOrEmpty(rs.Card[0].CardToken))
                    {
                        // We have a credit card
                        // prepare expiration date
                        DateTime expDate             = Util.GetLastDayOfThisMonth(Util.ConvertStringToDate(rs.Card[0].ExpirationDate, Const.DateFormat_MMyyyy));
                        string   shortExpirationDate = Util.ConvertDateToString(expDate, Const.DateFormat_MMyy);
                        // Set card type
                        string cardType      = rs.Card[0].CardType[0];
                        string shortCardType = CreditCardVerifier.GetShortCardTypeFromNavisionCardType(rs.Card[0].CardType[0]);
                        // Return the MII (first digit)
                        int mii = String.IsNullOrEmpty(rs.Card[0].TruncatedPAN) ? -1 : Util.ConvertStringToInt(rs.Card[0].TruncatedPAN.Substring(0, 1));

                        strData += Xml_Card_Open_Tag
                                   + Xml_CardType_Open_Tag + cardType + Xml_CardType_Close_Tag
                                   + Xml_ShortCardType_Open_Tag + CreditCardVerifier.GetShortCardTypeFromNavisionCardType(cardType) + Xml_ShortCardType_Close_Tag
                                   + Xml_CardToken_Open_Tag + rs.Card[0].CardToken + Xml_CardToken_Close_Tag
                                   + Xml_TruncatedCardNumber_Open_Tag + rs.Card[0].TruncatedPAN + Xml_TruncatedCardNumber_Close_Tag;

                        string pan;
                        try
                        {
                            // Untokenize
                            pan      = Services.GetPanFromBOToken(GetUser(), Util.ConvertStringToToken(rs.Card[0].CardToken));
                            strData += Xml_CardNumber_Open_Tag + pan + Xml_CardNumber_Close_Tag;
                        }catch (Exception e)
                        {
                            SetException(GetUser(), e.Message);
                            return(Const.XmlHeader
                                   + Xml_Response_Open_Tag
                                   + Xml_Response_Duration_Open_Tag
                                   + GetDuration()
                                   + Xml_Response_Duration_Close_Tag
                                   + BuildException()
                                   + Xml_Response_Close_Tag);
                        }

                        strData += Xml_FormOfPayment_Open_Tag +
                                   String.Format("FP CC{0}{1}/{2}", shortCardType, pan, shortExpirationDate.Replace("/", string.Empty))
                                   + Xml_FormOfPayment_Close_Tag
                                   + Xml_ExpirationDate_Open_Tag + Util.ConvertExpirationDateToString(expDate) + Xml_ExpirationDate_Close_Tag
                                   + Xml_ShortExpirationDate_Open_Tag + shortExpirationDate + Xml_ShortExpirationDate_Close_Tag
                                   + Xml_LodgedCard_Open_Tag + (rs.Card[0].LodgedCard[0].Equals("true") ? "1" : "0") + Xml_LodgedCard_Close_Tag
                                   + Xml_MII_Open_Tag + mii.ToString() + Xml_MII_Close_Tag
                                   + Xml_MIIIssuerCategory_Open_Tag + CreditCardVerifier.GetMIIIssuerCategory(mii) + Xml_MIIIssuerCategory_Close_Tag
                                   + Xml_MerchantFlow_Open_Tag + rs.Card[0].MerchandFlow + Xml_MerchantFlow_Close_Tag
                                   + Xml_EnhancedFlow_Open_Tag + rs.Card[0].EnhanceFlow + Xml_EnhancedFlow_Close_Tag

                                   + Xml_Card_Close_Tag;
                    }
                }

                strData += Xml_Response_Value_Close_Tag;
            }
            else
            {
                // On a une exception
                // Il faut renvoyer les tags d'exception et
                // de ce fait ne pas ajouter les tags sur les données
                strData += BuildException();
            }
            strData += Xml_Response_Close_Tag;

            return(strData);
        }
Esempio n. 4
0
        public async Task <ActionResult> ServiceBookingPage(ServiceRequestModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Logic for Authentificated User
                    if (User.Identity.IsAuthenticated)
                    {
                        GeneralUser user = await GetCurrentUserAsync();

                        Service          service          = repository.Services.Where(p => p.ServiceId == model.RequestedService.ServiceId).FirstOrDefault();
                        RequestedService requestedService = model.RequestedService;
                        Payment          payment          = model.Payment;
                        payment.UserId = user.Id;

                        requestedService.AddPayment(payment);
                        requestedService.UserId = user.Id;

                        //Calculates the resulted price after discount for registered user
                        requestedService.TotalPrice = requestedService.NumberOfHours * service.PricePerHour - (requestedService.NumberOfHours * service.PricePerHour * user.Discount / 100);

                        repository.AddPayment(payment);
                        repository.AddRequestedService(requestedService);

                        model.Discount         = user.Discount;
                        model.RequestedService = requestedService;
                        model.Service          = service;
                        model.User             = user;

                        return(RedirectToAction("BookingConfirmationPage", new BookingConfirmationModel {
                            Discount = model.Discount, ServiceId = model.Service.ServiceId, RequestedServiceId = model.RequestedService.RequestedServiceId, PaymentId = model.Payment.PaymentId
                        }));
                    }
                    //Logic for unregistered user
                    else
                    {
                        Service          service          = repository.Services.Where(p => p.ServiceId == model.RequestedService.ServiceId).FirstOrDefault();
                        RequestedService requestedService = model.RequestedService;
                        Payment          payment          = model.Payment;

                        requestedService.AddPayment(payment);

                        //Calculates resulted price of a requested service
                        requestedService.TotalPrice = requestedService.NumberOfHours * service.PricePerHour;

                        repository.AddRequestedService(requestedService);
                        model.RequestedService = requestedService;
                        model.Service          = service;

                        return(RedirectToAction("BookingConfirmationPage", new BookingConfirmationModel {
                            ServiceId = model.Service.ServiceId, RequestedServiceId = model.RequestedService.RequestedServiceId, PaymentId = model.Payment.PaymentId
                        }));
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }