/// <summary> /// /// </summary> /// <param name="idServiceDetail"></param> /// <returns></returns> public List <Question> GetQuestion(Guid idServiceDetail) { return(_questionDao.GetQuestion(idServiceDetail)); }
public List <MyTaskServicesViewModel> GetServiceListFromCampaign(Guid idCampaign, Guid idAccount, Guid idTask) { int numero_seccion = 0; var servicesParalel = new ConcurrentBag <MyTaskServicesViewModel>(); var campaignServices = _redisCache.Get <List <MyTaskServicesViewModel> >("CampaignServices:" + idCampaign); string idseccion = ""; if (campaignServices == null || idseccion != "") { var services = _campaignServicesDao.GetCampaignServicesByCampaign(idCampaign, idAccount); services.AsParallel() .ForAll(s => { servicesParalel.Add(new MyTaskServicesViewModel() { Code = s.Service.Code, Id = s.Service.Id, Name = s.Service.Name, Template = s.Service.Template, ServiceDetailCollection = GetSectionsFromService(s.IdService, idAccount, idTask) }); }); campaignServices = servicesParalel.ToList(); _redisCache.Set("CampaignServices:" + idCampaign, campaignServices); } //agregar seccion si es dinamica if (campaignServices != null) { int camp = 0; foreach (var q in campaignServices) { var s = q.ServiceDetailCollection.Where(x => x.IsDynamic == true).ToList(); if (s != null) { foreach (var a in s) { var preguntas = _questionDao.GetQuestion(a.Id).ToList(); numero_seccion = 0; foreach (var qtarea in preguntas) { var respuestas = _answerDao.GetAnswerListByQuestionAccount(qtarea.Id, idAccount, idTask).ToList().Count; if (respuestas > 1) { numero_seccion = respuestas; } } if (numero_seccion > 1) { int numero = 0; foreach (var n in q.ServiceDetailCollection.Where(x => x.Id == a.Id).ToList()) { if (numero > 0) { q.ServiceDetailCollection.Remove(n); } else { foreach (var ques in n.QuestionCollection) { ques.sequence = 0; } } numero++; } numero = 0; for (int numRep = 0; numRep < numero_seccion - 1; numRep++) { MyTaskServicesDetailViewModel SeccionInsertar = new MyTaskServicesDetailViewModel(); SeccionInsertar = GetSectionsFromServiceID(q.Id, idAccount, a.Id, numero + 1); q.ServiceDetailCollection.Insert(SeccionInsertar.Order, SeccionInsertar); numero++; } } else { var num = q.ServiceDetailCollection.Where(x => x.Id == a.Id).ToList(); int numero = 0; foreach (var n in q.ServiceDetailCollection.Where(x => x.Id == a.Id).ToList()) { if (numero > 0) { q.ServiceDetailCollection.Remove(n); } numero++; } } } } campaignServices[camp].ServiceDetailCollection.OrderBy(x => x.Order).ToList(); camp++; } } return(campaignServices); }