Пример #1
0
        public void Handle(AddPersonDocumentCommand command)
        {
            var repository = this.contextFactory();

            var person = _PersonDao.GetByPersonIntegrationId(command.PersonIntegrationId);

            var personDocument = new Domain.PersonDocument(command.PersonDocumentId, person.PersonId,
                                                           command.DocumentTypeId, command.Number, command.Complement, command.DateIssued,
                                                           command.DateValidUntil, DateTime.UtcNow, command.FileId, command.Active, command.UserSystemId);

            if (command.listFileTemp != null)
            {
                foreach (var item in command.listFileTemp)
                {
                    FIleServer fs = new FIleServer();

                    Domain.ReadModel.FileTemp fileTmp = new Domain.ReadModel.FileTemp();
                    fileTmp                = _FileTemp.Get(item);
                    fs.FilePath            = fileTmp.FilePath;
                    fs.Width               = fileTmp.Width;
                    fs.Height              = fileTmp.Height;
                    fs.OriginalName        = fileTmp.OriginalName;
                    fs.FileIntegrationCode = fileTmp.FileIntegrationCode;
                    fs.FileTempId          = item;
                    fs.Description         = "Usuário do Heeelp";
                    fs.FileUtilizationId   = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album);
                    fs.FriendlyName        = person.Name;
                    fs.Alt              = person.Name;
                    fs.Name             = person.Name;
                    fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User;
                    fs.PersonId         = command.PersonId;
                    fs.UploadedBy       = command.UserSystemId;

                    var ret = fs.SendFilePath(fs);

                    if (ret > 0)
                    {
                        _FileTemp.Delete(fs.FileTempId);
                        personDocument.FileId = ret;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
            }

            repository.Save(personDocument);
        }
Пример #2
0
        public void Handle(AddExpertiseCommand command)
        {
            var repository = this.contextFactory();
            //command.CreatedBy = 0;
            var expertise = new Domain.Expertise(Guid.NewGuid(), command.ExpertiseId, command.Name, command.ExpertiseFatherId, command.CreatedBy, command.CreatedDateUTC, command.ApprovalStatusId,
                                                 command.ApprovedBy, command.ApprovedDate, command.DefaultDescription, command.IsPriceDefinedEditorially, command.ApprovalStatus, command.Expertise1,
                                                 command.Expertise2, command.User, command.User1, command.Active);

            repository.Save(expertise);


            foreach (var item in command.listFileTemp)
            {
                FIleServer fs = new FIleServer();

                Domain.ReadModel.FileTemp fileTmp = new Domain.ReadModel.FileTemp();
                fileTmp                = _FileTemp.Get(item);
                fs.FilePath            = fileTmp.FilePath;
                fs.Width               = fileTmp.Width;
                fs.Height              = fileTmp.Height;
                fs.OriginalName        = fileTmp.OriginalName;
                fs.FileIntegrationCode = fileTmp.FileIntegrationCode;
                fileTempId             = item;
                fs.FileTempId          = fileTempId;
                fs.Description         = "Usuário do Heeelp";
                fs.FileUtilizationId   = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album);
                fs.FriendlyName        = command.Name;
                fs.Alt              = command.Name;
                fs.Name             = command.Name;
                fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User;
                fs.PersonId         = command.PersonId;
                fs.UploadedBy       = command.CreatedBy;
                expertise.CompleteSuccessFile(fs);
                // repository.Save(expertise);
            }



            expertise.Complete();
            repository.Save(expertise);
        }
Пример #3
0
        public void Handle(AddPromotionProspectCommand command)
        {
            var person = _PersonDao.GetByPersonIntegrationId(command.PersonIntegrationID);

            command.PersonId = person.PersonId;
            List <long> listImgIds = new List <long>();

            if (command.listFileTemp != null)
            {
                foreach (var item in command.listFileTemp)
                {
                    FIleServer fs = new FIleServer();

                    Domain.ReadModel.FileTemp fileTmp = new Domain.ReadModel.FileTemp();
                    fileTmp                = _FileTemp.Get(item);
                    fs.FilePath            = fileTmp.FilePath;
                    fs.Width               = fileTmp.Width;
                    fs.Height              = fileTmp.Height;
                    fs.OriginalName        = fileTmp.OriginalName.Replace(".jpg.jpeg", ".jpg");
                    fs.FileIntegrationCode = fileTmp.FileIntegrationCode;
                    fs.FileTempId          = item;
                    fs.Description         = "Usuário do Heeelp";
                    fs.FileUtilizationId   = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album);
                    fs.FriendlyName        = fileTmp.OriginalName;
                    fs.Alt              = fileTmp.OriginalName;
                    fs.Name             = fileTmp.OriginalName;
                    fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User;
                    fs.PersonId         = command.PersonId;
                    fs.UploadedBy       = Convert.ToInt32(command.UserSystemId);
                    var ret = fs.SendFilePath(fs);
                    if (ret > 0)
                    {
                        listImgIds.Add(ret);
                        _FileTemp.Delete(fs.FileTempId);
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
            }
            command.FilesIdList = listImgIds;



            string url = string.Empty;

            switch ((GeneralEnumerators.enumPromotionType)command.PromotionTypeId)
            {
            case GeneralEnumerators.enumPromotionType.Discount:
                url = "api/Promotion/AddDiscountPromotion";
                break;

            case GeneralEnumerators.enumPromotionType.Award:
                url = "api/Promotion/AddAwardPromotion";
                break;

            case GeneralEnumerators.enumPromotionType.Gift:
                url = "api/Promotion/AddGiftPromotion";
                break;
            }


            var _clientPromotion = new HttpClient();

            _clientPromotion.BaseAddress = new Uri(CustomConfiguration.WebApiPromotion);
            var resultTask = _clientPromotion.PostAsJsonAsync(url, command).Result;

            if (!resultTask.IsSuccessStatusCode)
            {
                LogManager.Error(url + " Handler: Erro ao enviar web.api promotion:  status: " + resultTask.StatusCode);
            }
            else
            {
                resultTask = _clientPromotion.PostAsJsonAsync("api/Promotion/UploadPromotionPhoto", command).Result;
                if (!resultTask.IsSuccessStatusCode)
                {
                    LogManager.Error("UploadPromotionPhoto Handler: Erro ao enviar web.api promotion:  status: " + resultTask.StatusCode);
                }
            }
        }