public EventController() { string connectionString = ConfigurationManager.ConnectionStrings["conexao"].ToString(); eventRepository = new EventRepository(connectionString); eventApplication = new EventApplication(eventRepository); }
private decimal?GetFinalGrade(EventApplication application) { if (application.InorganicGrade.HasValue && application.OrganicGrade.HasValue) { var sum = application.InorganicGrade.Value + application.OrganicGrade.Value; return(Math.Round(sum / 2, 2)); } return(null); }
private async Task SetEventProgress(List <Event> events, ObjectId userId, UserInfoDB userInfo, CancellationToken token) { var eventId = ObjectId.Parse(userInfo.IdModuloEvento); var currentEvent = events.FirstOrDefault(t => t.Id == eventId); if (currentEvent != null) { if (currentEvent.Schedules == null) { await LogProductError("ScheduleDoesntExist", userInfo, userId, token); return; } decimal grade = CellIsEmpty(userInfo.Pontuacao) ? 0 : decimal.Parse(userInfo.Pontuacao.Replace(".", ",")); var schedule = currentEvent.Schedules.FirstOrDefault(); if (schedule == null) { await LogProductError("ScheduleDoesntExist", userInfo, userId, token); } else { var application = new EventApplication() { UserId = userId, EventId = currentEvent.Id, ScheduleId = schedule.Id, EventDate = schedule.EventDate, ApplicationStatus = ApplicationStatus.Approved, RequestedDate = DateTimeOffset.Now, ResolutionDate = DateTimeOffset.Now, OrganicGrade = grade, InorganicGrade = grade, UserPresence = true }; application.GradeBaseValues = new List <BaseValue>(); if (!CellIsEmpty(userInfo.CC)) { application.GradeBaseValues.Add(new BaseValue() { Key = "CC", Value = userInfo.CC }); } if (!CellIsEmpty(userInfo.CS)) { application.GradeBaseValues.Add(new BaseValue() { Key = "CS", Value = userInfo.CS }); } if (!CellIsEmpty(userInfo.CCS)) { application.GradeBaseValues.Add(new BaseValue() { Key = "CCS", Value = userInfo.CCS }); } if (!CellIsEmpty(userInfo.REIPODO)) { application.GradeBaseValues.Add(new BaseValue() { Key = "REIPODO", Value = userInfo.REIPODO }); } if (!CellIsEmpty(userInfo.ADODO)) { application.GradeBaseValues.Add(new BaseValue() { Key = "ADODO", Value = userInfo.ADODO }); } if (!CellIsEmpty(userInfo.EAEDO)) { application.GradeBaseValues.Add(new BaseValue() { Key = "EAEDO", Value = userInfo.EAEDO }); } if (!CellIsEmpty(userInfo.PA)) { application.GradeBaseValues.Add(new BaseValue() { Key = "PA", Value = userInfo.PA }); } if (!CellIsEmpty(userInfo.FA)) { application.GradeBaseValues.Add(new BaseValue() { Key = "FA", Value = userInfo.FA }); } if (!CellIsEmpty(userInfo.EA)) { application.GradeBaseValues.Add(new BaseValue() { Key = "EA", Value = userInfo.EA }); } if (!CellIsEmpty(userInfo.CapacidadeTecnica)) { application.GradeBaseValues.Add(new BaseValue() { Key = "CapacidadeTecnica", Value = userInfo.CapacidadeTecnica }); } if (!CellIsEmpty(userInfo.Postura)) { application.GradeBaseValues.Add(new BaseValue() { Key = "Postura", Value = userInfo.Postura }); } if (!CellIsEmpty(userInfo.Argumentacao)) { application.GradeBaseValues.Add(new BaseValue() { Key = "Argumentacao", Value = userInfo.Argumentacao }); } if (!CellIsEmpty(userInfo.Articulacao)) { application.GradeBaseValues.Add(new BaseValue() { Key = "Articulacao", Value = userInfo.Articulacao }); } if (!CellIsEmpty(userInfo.Negociacao)) { application.GradeBaseValues.Add(new BaseValue() { Key = "Negociacao", Value = userInfo.Negociacao }); } await _db.EventApplicationCollection.InsertOneAsync( application, cancellationToken : token ); } } }