public void AddDeliveryPoint(StoragePoint deliveryPoint)
 {
     DeliveryPoints.Add(deliveryPoint);
     _addDeliveryPointEvent.Publish(new AddDeliveryPointEvent {
         DeliveryPoint = deliveryPoint
     });
 }
Exemple #2
0
        public ClientVisitSaveDataModel(User user, ClientVisit clientVisit)
            : this(user)
        {
            VisitId                       = clientVisit.Id;
            ClientId                      = clientVisit.ClientId;
            VisitGroupId                  = clientVisit.VisitGroupId;
            SignatureFileName             = clientVisit.SignatureFileName ?? Guid.NewGuid().ToString();
            PhotoFileName                 = clientVisit.PhotoFileName ?? Guid.NewGuid().ToString();
            DeliveryCenterId              = clientVisit.DeliveryCenter.Id;
            ScenarioId                    = clientVisit.Scenario != null ? clientVisit.Scenario.Id : new long?();
            TemporaryPolicyDate           = clientVisit.TemporaryPolicyDate;
            TemporaryPolicyNumber         = clientVisit.TemporaryPolicyNumber;
            TemporaryPolicyExpirationDate = clientVisit.TemporaryPolicyExpirationDate;
            StatusId                      = clientVisit.Status.Id;
            StatusDate                    = clientVisit.StatusDate;
            StatusEnabled                 = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG);
            DisableAll                    = clientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id &&
                                            !(user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG));
            OldClientInfo           = new ClientVersionEditModel(clientVisit.OldClientInfo, EntityType.Old);
            NewClientInfo           = new ClientVersionEditModel(clientVisit.NewClientInfo, EntityType.New);
            OldDocument             = new DocumentModel(clientVisit.OldDocument, DocumentType.Old);
            NewDocument             = new DocumentModel(clientVisit.NewDocument, DocumentType.New);
            NewForeignDocument      = new DocumentModel(clientVisit.NewForeignDocument, DocumentType.NewForeign);
            OldForeignDocument      = new DocumentModel(clientVisit.OldForeignDocument, DocumentType.OldForeign);
            LivingAddress           = new AddressModel(clientVisit.LivingAddress, AddressType.Living);
            RegistrationAddress     = new AddressModel(clientVisit.RegistrationAddress, AddressType.Registration);
            RegistrationAddressDate = clientVisit.RegistrationAddressDate;
            OldPolicy                 = new PolicyInfoClientVisitSaveModel(clientVisit.OldPolicy, EntityType.Old);
            NewPolicy                 = new PolicyInfoClientVisitSaveModel(clientVisit.NewPolicy, EntityType.New);
            Registrator               = new UserModel(clientVisit.Registrator);
            Representative            = new RepresentativeEditModel(clientVisit.Representative);
            CarrierId                 = clientVisit.CarrierId;
            ApplicationMethodId       = clientVisit.ApplicationMethodId;
            Comment                   = clientVisit.Comment;
            GOZNAKDate                = clientVisit.GOZNAKDate;
            GOZNAKTypeId              = clientVisit.GOZNAKType != null ? clientVisit.GOZNAKType.Id : default(long?);
            ClientCategoryId          = clientVisit.ClientCategoryId == 0 ? new long() : clientVisit.ClientCategoryId;
            DeliveryPointId           = clientVisit.DeliveryPointId == 0 ? new long() : clientVisit.DeliveryPointId;
            ClientAcquisitionEmployee = clientVisit.ClientAcquisitionEmployee;
            ClientContacts            = clientVisit.ClientContacts;
            Phone          = clientVisit.Phone;
            Email          = clientVisit.Email;
            IssueDate      = clientVisit.IssueDate;
            UralsibCard    = clientVisit.UralsibCard;
            IsActual       = clientVisit.IsActual;
            Scenaries      = ReferencesProvider.GetReferences(Constants.ScenarioRef, user.Roles, DateTime.Now, null, true);
            DeliveryPoints = ReferencesProvider.GetReferences(Constants.DeliveryPointRef, user.Roles, DateTime.Now, null, true);
            ListClientAcquisitionEmployee = ReferencesProvider.GetListClientAcquisitionEmployee(null, true);
            PolicyBlanc = clientVisit.PolicyBlanc;

            if (ScenarioId != 0 && !Scenaries.Exists(item => item.Value == ScenarioId.ToString()))
            {
                Scenaries.Add(ReferencesProvider.GetReferences(Constants.ScenarioRef).FirstOrDefault(item => item.Value == ScenarioId.ToString()));
            }
            if (DeliveryPointId.HasValue && !DeliveryPoints.Exists(item => item.Value == DeliveryPointId.Value.ToString()))
            {
                DeliveryPoints.Add(ReferencesProvider.GetReferences(Constants.DeliveryPointRef).FirstOrDefault(item => item.Value == DeliveryPointId.Value.ToString()));
            }
            if (ClientCategoryId.HasValue && !UralsibClientCategories.Exists(item => item.Value == ClientCategoryId.Value.ToString()))
            {
                UralsibClientCategories.Add(ReferencesProvider.GetReferences(Constants.UralsibClientCategoryRef).FirstOrDefault(item => item.Value == ClientCategoryId.Value.ToString()));
            }
            IssueDateEnabled = (user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG)) ||
                               (StatusId == ClientVisitStatuses.PolicyReadyForClient.Id && user.Roles.Contains(Role.Registrator));
            IsReadyToFundSubmitRequestEnabled = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG);
            PolicyPartyNumber           = clientVisit.PolicyPartyNumber;
            FundResponseApplyingMessage = clientVisit.FundResponseApplyingMessage;
            IsReadyToFundSubmitRequest  = clientVisit.IsReadyToFundSubmitRequest;
            CreateDate       = clientVisit.CreateDate;
            UpdateDate       = clientVisit.UpdateDate;
            IsDifficultCase  = clientVisit.IsDifficultCase;
            AttachmentDate   = clientVisit.AttachmentDate;
            AttachmentTypeId = clientVisit.AttachmentType != null ? clientVisit.AttachmentType.Id : new long?();
            MedicalCentreId  = clientVisit.MedicalCentre != null ? clientVisit.MedicalCentre.Id : new long?();
        }