public int Create(GradeDetails gradeDetails) { IMapper mapper = GetMapperForEntity(); var grade = mapper.Map <Grade>(gradeDetails); return(GradeRepository.Insert(grade)); }
public IHttpActionResult PostGrade(GradeDetails gradeDetails) { IHttpActionResult result; if (ModelState.IsValid) { int gradeId = GradeService.Create(gradeDetails); result = Ok(gradeId); } else { result = BadRequest(ModelState); } return(result); }
private void GradesDetails_Load(object sender, RoutedEventArgs e) { using SQLiteCommand cmd = GlobalFunction.OpenDbConnection(); cmd.CommandText = $"SELECT * FROM grades WHERE studentId = {studentId}"; using SQLiteDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { int creationDateTimestamp = rdr.GetInt32(4); DateTime creationDateTime = DateTimeOffset.FromUnixTimeSeconds(creationDateTimestamp).LocalDateTime; GradeDetails gradeDetail = new GradeDetails() { CreationDate = creationDateTime.ToString("g", GlobalVariable.culture), Grade = rdr.GetFloat(2).ToString(), Coefficient = rdr.GetInt32(3).ToString(), Title = rdr.GetString(4) }; gradeCollection.Add(gradeDetail); } }
private void GetGrades() { log.Debug("GradesViewModel: Trying to get grades."); var newGrades = new MvxObservableCollection <GradeDetails>(); if (fcsService.FCSConfig == null) { log.Error("GradesViewModel: Fcs configuration is null."); return; } fcsService.FCSConfig.FuelPrice.Grades.ForEach( grade => newGrades.Add(new GradeDetails() { Decimal = FuelUnitPriceDecimal, CurrentData = grade })); SelectedGrade = null; Grades = newGrades; log.Debug("GradesViewModel: Finished fetching all grades."); }