示例#1
0
        public MobileResponseModel Save(GiftCertificateSignatureModel model)
        {
            try
            {
                var GCReasionId = model.GcNotGivenReasonId != null ? model.GcNotGivenReasonId : 0;
                _logger.Info("Gift Card (Save) : EventCustomerId Id :" + model.EventCustomerId);
                _logger.Info("Gift Card (Save) : GcNotGivenReasonId :" + GCReasionId);
                _logger.Info("Gift Card (Save) : GiftCardReceived :" + model.GiftCardReceived);

                var eventCustomer = ((IUniqueItemRepository <EventCustomer>)_eventCustomerRepository).GetById(model.EventCustomerId);

                var eventId = eventCustomer != null ? eventCustomer.EventId : 0;

                CorporateAccount account = null;

                if (eventId > 0)
                {
                    account = _corporateAccountRepository.GetbyEventId(eventId);
                }
                if (account != null)
                {
                    _logger.Info("Account Tag : " + account.Tag + "  AttachGiftCard : " + account.AttachGiftCard + "  ShowGiftCertificateOnEod : " + account.ShowGiftCertificateOnEod);
                }

                if ((account != null && account.AttachGiftCard) && !model.GiftCardReceived && (model.GcNotGivenReasonId == null || (model.GcNotGivenReasonId != null && model.GcNotGivenReasonId == 0)))
                {
                    return(new MobileResponseModel
                    {
                        IsSuccess = false,
                        Message = "Unable to save the Gift Card because GC not given reason Id is null"
                    });
                }

                var isSuccess = _giftCardService.Save(model, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);

                if (isSuccess)
                {
                    return(new MobileResponseModel
                    {
                        IsSuccess = true,
                        Message = "Gift Card saved successfully."
                    });
                }
                else
                {
                    return(new MobileResponseModel
                    {
                        IsSuccess = false,
                        Message = "Unable to save the Gift Card."
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error while saving Gift Card.");
                _logger.Error("Message : " + ex.Message);
                _logger.Error("Stack Trace : " + ex.StackTrace);

                return(new MobileResponseModel
                {
                    IsSuccess = false,
                    Message = string.Format("Error while saving Gift Card. Message : {0}", ex.Message)
                });
            }
        }
示例#2
0
        public bool Save(GiftCertificateSignatureModel model, long orgRoleUserId)
        {
            var evenntCustomer = _eventCustomerRepository.GetById(model.EventCustomerId);

            if (evenntCustomer == null)
            {
                return(false);
            }

            var signatureLocation = _mediaRepository.GetGiftCardSignatureLocation(evenntCustomer.EventId,
                                                                                  evenntCustomer.CustomerId);

            var version = _eventCustomerGiftCardRepository.GetLatestVersion(model.EventCustomerId);

            var giftCardSignature = new EventCustomerGiftCard()
            {
                EventCustomerId  = model.EventCustomerId,
                GiftCardReceived = model.GiftCardReceived,
                Version          = version,
                IsActive         = true,
                CreatedBy        = orgRoleUserId,
                DateCreated      = DateTime.Now
            };

            if (!string.IsNullOrWhiteSpace(model.PatientSignatureBytes))
            {
                var fileName = "PatientSignature_GiftCard_" + Guid.NewGuid() + ".jpg";

                var patientImageFile = SaveSignatureImage(model.PatientSignatureBytes, orgRoleUserId, signatureLocation, fileName);

                giftCardSignature.PatientSignatureFileId = patientImageFile.Id;
            }

            if (!string.IsNullOrWhiteSpace(model.TechnicianSignatureBytes))
            {
                var fileName = "TechnicianSignature_GiftCard_" + Guid.NewGuid() + ".jpg";

                var technicianImageFile = SaveSignatureImage(model.TechnicianSignatureBytes, orgRoleUserId, signatureLocation, fileName);

                giftCardSignature.TechnicianSignatureFileId = technicianImageFile.Id;
            }

            _eventCustomerGiftCardRepository.Save(giftCardSignature);

            if (model.GiftCardReceived)
            {
                evenntCustomer.IsGiftCertificateDelivered = true;
                evenntCustomer.GiftCode = model.GiftCardNumber;
                _eventCustomerRepository.Save(evenntCustomer);
            }
            else
            {
                if (model.GcNotGivenReasonId != null && model.GcNotGivenReasonId > 0)
                {
                    evenntCustomer.GcNotGivenReasonId         = model.GcNotGivenReasonId;
                    evenntCustomer.IsGiftCertificateDelivered = false;
                    _eventCustomerRepository.Save(evenntCustomer);
                }
            }

            return(true);
        }