Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Text;
- using ExcercisesDAL;
- namespace ExercisesViewModels
- {
- public class GradeViewModel
- {
- private GradeModel _model;
- public int Id { get; set; }
- public int StudentId { get; set; }
- public int CourseId { get; set; }
- public int Mark { get; set; }
- public string Comments { get; set; }
- public string Timer { get; set; }
- //constructor
- public GradeViewModel()
- {
- _model = new GradeModel();
- }
- //methods
- public List<GradeViewModel> GetAll(int id)
- {
- List<GradeViewModel> allVms = new List<GradeViewModel>();
- try
- {
- List<Grades> allGrades = _model.GetAllGrades(id);
- foreach (Grades grd in allGrades)
- {
- GradeViewModel grdVm = new GradeViewModel();
- grdVm.Id = grd.Id;
- grdVm.Mark = grd.Mark;
- grdVm.StudentId = grd.StudentId;
- grdVm.CourseId = grd.CourseId;
- grdVm.Comments = grd.Comments;
- grdVm.Timer = Convert.ToBase64String(grd.Timer);
- allVms.Add(grdVm);
- }
- }
- catch (Exception ex)
- {
- Console.Write("Problem in " + GetType().Name + " " +
- MethodBase.GetCurrentMethod().Name + " " + ex.Message);
- throw ex;
- }
- return allVms;
- }
- public int Update()
- {
- UpdateStatus gradesUpdated = UpdateStatus.Failed;
- try
- {
- Grades grd = new Grades();
- grd.Id = Id;
- grd.StudentId = StudentId;
- grd.CourseId = CourseId;
- grd.Mark = Mark;
- grd.Comments = Comments;
- grd.Timer = Convert.FromBase64String(Timer);
- gradesUpdated = _model.Update(grd);
- }
- catch (Exception ex)
- {
- Console.Write("Problem in " + GetType().Name + " " +
- MethodBase.GetCurrentMethod().Name + " " + ex.Message);
- throw ex;
- }
- return Convert.ToInt16(gradesUpdated);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement