コード例 #1
0
        /// <summary>
        /// Mocks the DB context that it contains the entries given as paramether.
        /// </summary>
        /// <param name="dataList">The list of all the entries that should be in the database</param>
        /// <param name="pasteList">The list of all the entries of pastes that should be in the database</param>
        /// <exception cref="NotImplementedException">Thrown then context.Entry function is called</exception>
        public void getDbContext(List <Rating> dataList, List <Paste> pasteList)
        {
            var data  = dataList.AsQueryable();
            var dataP = pasteList.AsQueryable();

            mockSet  = new Mock <DbSet <Rating> >();
            mockSetP = new Mock <DbSet <Paste> >();

            mockSet.As <IQueryable <Rating> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Rating> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Rating> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Rating> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            mockSetP.As <IQueryable <Paste> >().Setup(m => m.Provider).Returns(dataP.Provider);
            mockSetP.As <IQueryable <Paste> >().Setup(m => m.Expression).Returns(dataP.Expression);
            mockSetP.As <IQueryable <Paste> >().Setup(m => m.ElementType).Returns(dataP.ElementType);
            mockSetP.As <IQueryable <Paste> >().Setup(m => m.GetEnumerator()).Returns(dataP.GetEnumerator());

            mockContext = new Mock <DBContext>();
            mockContext.Setup(x => x.Ratings).Returns(mockSet.Object);
            mockContext.Setup(x => x.Pastes).Returns(mockSetP.Object);
            mockContext.Setup(x => x.Entry(It.IsAny <Rating>())).Throws(new NotImplementedException());

            db = new RatingBusiness(mockContext.Object);
        }
コード例 #2
0
        public StudentsGDP()
        {
            InitializeComponent();
            IRatingRepository ratingRepository = new RatingRepository();

            this.ratingBusiness = new RatingBusiness(ratingRepository);
        }
コード例 #3
0
        public RatingsForm()
        {
            InitializeComponent();
            IRatingRepository  ratingRepository  = new RatingRepository();
            IStudentRepository studentRepository = new StudentRepository();
            ICourseRepository  courseRepository  = new CourseRepository();

            this.ratingBusiness  = new RatingBusiness(ratingRepository);
            this.studentBusiness = new StudentBusiness(studentRepository);
            this.courseBusiness  = new CourseBusiness(courseRepository);
        }
コード例 #4
0
 public object DisplayRating(TeacherRatingParam obj)
 {
     try
     {
         RatingBusiness objp = new RatingBusiness();
         var            Rate = objp.DisplayMark(obj);
         return(Rate);
     }
     catch (Exception e)
     {
         return(new Error()
         {
             IsError = true, Message = e.Message
         });
     }
 }
コード例 #5
0
ファイル: RatingService.cs プロジェクト: MagninM/MCGA2017
        public Rating Add(Rating rating)
        {
            try
            {
                var br = new RatingBusiness();
                return(br.Add(rating));
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
コード例 #6
0
ファイル: RatingService.cs プロジェクト: MagninM/MCGA2017
        public void Remove(int id)
        {
            try
            {
                var br = new RatingBusiness();
                br.Remove(id);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
コード例 #7
0
ファイル: RatingService.cs プロジェクト: MagninM/MCGA2017
        public void Edit(Rating rating)
        {
            try
            {
                var br = new RatingBusiness();
                rating.ChangedOn = System.DateTime.Now;
                br.Edit(rating);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }
コード例 #8
0
ファイル: RatingService.cs プロジェクト: MagninM/MCGA2017
        public FindRatingResponse Find(int id)
        {
            try
            {
                var response = new FindRatingResponse();
                var br       = new RatingBusiness();
                response.Result = br.Find(id);
                return(response);
            }
            catch (Exception ex)
            {
                var httpError = new HttpResponseMessage()
                {
                    StatusCode   = (HttpStatusCode)422,
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(httpError);
            }
        }