public async Task <NOMSurveyReplyResult> CreateAsync(NOMSurveyReplyParams nOMSurveyReplyParams) { string serializedResult = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, _authorizationHeader, new Uri($"{_cotorraUri}"), new object[] { nOMSurveyReplyParams }); if (!String.IsNullOrEmpty(serializedResult)) { return(JsonConvert.DeserializeObject <NOMSurveyReplyResult>(serializedResult)); } return(default);
public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : class { //EvaluationPeriod var nomEvaluationPeriod = new NOMEvaluationPeriod() { ID = Guid.NewGuid(), Active = true, Timestamp = DateTime.UtcNow, Description = "Soy una surveyreply", CreationDate = DateTime.Now, company = identityWorkId, user = Guid.NewGuid(), InstanceID = instanceId, Name = "g1", StatusID = 1, InitialDate = DateTime.Now, FinalDate = DateTime.Now.AddDays(1), Period = "2019", State = true, }; var lstNomEvaluationPeriods = new List <NOMEvaluationPeriod>(); lstNomEvaluationPeriods.Add(nomEvaluationPeriod); var middlewareManagerEvaluationPeriod = new MiddlewareManager <NOMEvaluationPeriod>(new BaseRecordManager <NOMEvaluationPeriod>(), new NOMEvaluationPeriodValidator()); middlewareManagerEvaluationPeriod.Create(lstNomEvaluationPeriods, identityWorkId); //Employee var lstEmployees = await new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId, instanceId, randomValues: true); var nomSurveyReply = new NOMSurveyReplyParams() { EmployeeId = lstEmployees.FirstOrDefault().ID, NOMEvaluationPeriodId = nomEvaluationPeriod.ID, NOMEvaluationSurveyId = Guid.Parse("612A7938-1D11-4400-8BB7-AD29191AC33C"), IdentityWorkId = identityWorkId, InstanceId = instanceId }; var manager = new NOMSurveyManager(); var res = await manager.CreateAsync(nomSurveyReply); return(new List <T>() { res as T }); }
public async Task <NOMSurveyReplyResult> CreateAsync(NOMSurveyReplyParams nOMSurveyReplyParams) { BeforeCreate(nOMSurveyReplyParams); var result = new NOMSurveyReplyResult(); using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); var NOMSurveyReply = CreateDefault( nOMSurveyReplyParams.IdentityWorkId, nOMSurveyReplyParams.InstanceId, nOMSurveyReplyParams.EmployeeId, nOMSurveyReplyParams.NOMEvaluationPeriodId, nOMSurveyReplyParams.NOMEvaluationSurveyId); await SetAnswers(NOMSurveyReply); //middleware instance var middlewareManager = new MiddlewareManager <NOMSurveyReply>(new BaseRecordManager <NOMSurveyReply>(), new NOMSurveyReplyValidator()); //Get var resultPrevious = await middlewareManager.FindByExpressionAsync(p => p.EmployeeID == nOMSurveyReplyParams.EmployeeId && p.EvaluationState != EvaluationStateType.Answered && p.NOMEvaluationPeriod.ID == nOMSurveyReplyParams.NOMEvaluationPeriodId, nOMSurveyReplyParams.IdentityWorkId); //verify if exists pending surverreply for employee if (!resultPrevious.Any()) { //Create var lstToCreate = new List <NOMSurveyReply>(); lstToCreate.Add(NOMSurveyReply); await middlewareManager.CreateAsync(lstToCreate, nOMSurveyReplyParams.IdentityWorkId); } //Encrypt and encode de token var encrypted = StringCipher.Encrypt(NOMSurveyReply.ID.ToString()); var encryptedEncoded = HttpUtility.UrlEncode(encrypted); result.NOMSurveyReply = NOMSurveyReply; result.Token = encryptedEncoded; scope.Complete(); return(result); }
private void BeforeCreate(NOMSurveyReplyParams nOMSurveyReplyParams) { //validations }
public async Task <NOMSurveyReplyResult> CreateAsync(NOMSurveyReplyParams nOMSurveyReplyParams) { return(await new NOMSurveyManager().CreateAsync(nOMSurveyReplyParams)); }
public async Task <NOMSurveyReplyResult> CreateAsync(NOMSurveyReplyParams nOMSurveyReplyParams) { return(await _client.CreateAsync(nOMSurveyReplyParams)); }