private async Task <Guid?> CreateProcess() { Guid?situationId = null; if (!string.IsNullOrEmpty(Variable.SituationId)) { var situationRepository = Repository.CatalogContext.Set <SituationEntity>(); situationId = ((await situationRepository.ToListAsync()).First(situation => situation.Name.Trim().ToUpper() == Variable.SituationId.Trim().ToUpper())).Id; } var responsibleRepository = Repository.CatalogContext.Set <ResponsibleEntity>(); ResponsibleEntity responsibleEntity = null; if (!string.IsNullOrEmpty(Variable.ResponsiblesCpf) && !string.IsNullOrEmpty(Variable.ResponsiblesName) && !string.IsNullOrEmpty(Variable.ResponsiblesEMail) && !string.IsNullOrEmpty(Variable.Image)) { responsibleEntity = (await responsibleRepository.AddAsync(new ResponsibleEntity { Cpf = Convert.ToInt64(Variable.ResponsiblesCpf.Replace(".", "").Replace("-", "")), Name = Variable.ResponsiblesName, Mail = Variable.ResponsiblesEMail, Photograph = Variable.Image, })).Entity; } var processRepository = Repository.CatalogContext.Set <ProcessEntity>(); var processEntity = (await processRepository.AddAsync(new ProcessEntity { JusticeSecret = (bool?)(Variable.JusticeSecret == "S" ? true : false), Description = Variable.Description, SituationId = situationId, UnifiedProcessNumber = Variable.UnifiedProcessNumber, ClientPhysicalFolder = Variable.ClientPhysicalFolder, UpdateDate = DateTime.Now.Date, UpdateUserName = "******", DistributionDate = (DateTime?)DateTime.ParseExact(Variable.DistributionDate, "yyyy-MM-dd", CultureInfo.CreateSpecificCulture("pt-BR")), Version = 1, ProcessResponsible = new List <ProcessResponsibleEntity>() { new ProcessResponsibleEntity { ResponsibleId = responsibleEntity.Id } } })).Entity; await Repository.CatalogContext.SaveChangesAsync(); return(processEntity.Id); }
public static ResponsibleResponseTO ToResponsibleResponseTO(this ResponsibleEntity responsibleEntity) { if (responsibleEntity == null) { return(null); } return(new ResponsibleResponseTO() { Id = responsibleEntity.Id, Cpf = responsibleEntity.Cpf, Name = responsibleEntity.Name, Mail = responsibleEntity.Mail, Photograph = responsibleEntity.Photograph, }); }