Example #1
0
        public void RemoveFromSchedule()
        {
            CheckConditionsForRemoveFromSchedule();

            Status = LessonStatus.NonActive;
            storage.Update(this);
        }
Example #2
0
        public async Task <IActionResult> Add([FromForm] LessonStatusModel model)
        {
            try
            {
                if (this.ValidRoleForAction(_context, _auth, new string[] { "Admin" }))
                {
                    bool saved;
                    if (ModelState.IsValid)
                    {
                        LessonStatus item = new LessonStatus
                        {
                            Name = model.Name,
                        };

                        await _context.Add(item);

                        saved = await _context.SaveAll();

                        if (saved == true)
                        {
                            return(Ok(item));
                        }
                    }
                    return(BadRequest("Model is not valid"));
                }
                return(Forbid());
            }
            catch (Exception ex)
            {
                var arguments = this.GetBaseData(_context, _auth);
                _logger.LogException(ex, arguments.Email, arguments.Path);
                return(BadRequest($"{ex.GetType().Name} was thrown."));
            }
        }
Example #3
0
        public void Cancel()
        {
            CheckConditionsForCancel();

            Status = LessonStatus.Canceled;
            storage.Update(this);
        }
Example #4
0
        public void Restore()
        {
            CheckConditionsForRestore();

            Status = LessonStatus.NonActive;
            storage.Update(this);
        }
Example #5
0
 private Lesson(DateTime dateTime, int lengthInMinutes, Order order)
 {
     DateTime        = dateTime;
     LengthInMinutes = lengthInMinutes;
     Order           = order;
     Status          = LessonStatus.NonActive;
 }
Example #6
0
        public void AddToSchedule()
        {
            var inters = GetIntersectionWithScheduled(this);

            CheckConditionsForAddToSchedule(inters);

            this.Status = LessonStatus.Active;
            storage.Update(this);
        }
        public async Task <Exam> ChangeStatus(int id, LessonStatus newStatus)
        {
            var exam = this.GetExamById(id);

            exam.Status = newStatus;
            this.examRepository.Update(exam);
            await this.examRepository.SaveChangesAsync();

            return(exam);
        }
Example #8
0
        public virtual LessonStatus MapBOToEF(
            BOLessonStatus bo)
        {
            LessonStatus efLessonStatus = new LessonStatus();

            efLessonStatus.SetProperties(
                bo.Id,
                bo.Name,
                bo.StudioId);
            return(efLessonStatus);
        }
Example #9
0
        public virtual BOLessonStatus MapEFToBO(
            LessonStatus ef)
        {
            var bo = new BOLessonStatus();

            bo.SetProperties(
                ef.Id,
                ef.Name,
                ef.StudioId);
            return(bo);
        }
Example #10
0
        public void Renew()
        {
            CheckConditionsForRenew();

            Status = LessonStatus.Active;
            foreach (var student in Order.Students)
            {
                student.Client.IncreaseBalance(
                    Order.GetCostPerHourFor(student) * LengthInMinutes / MinutesInHour
                    );
            }
            storage.Update(this);
        }
Example #11
0
        public void MapBOToEF()
        {
            var mapper = new DALLessonStatusMapper();
            var bo     = new BOLessonStatus();

            bo.SetProperties(1, "A", 1);

            LessonStatus response = mapper.MapBOToEF(bo);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.StudioId.Should().Be(1);
        }
Example #12
0
        public void MapEFToBO()
        {
            var          mapper = new DALLessonStatusMapper();
            LessonStatus entity = new LessonStatus();

            entity.SetProperties(1, "A", 1);

            BOLessonStatus response = mapper.MapEFToBO(entity);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.StudioId.Should().Be(1);
        }
Example #13
0
        public void Complete()
        {
            CheckConditionsForComplete();

            Status = LessonStatus.Completed;
            foreach (var student in Order.Students)
            {
                student.Client.DecreaseBalance(
                    Order.GetCostPerHourFor(student) * LengthInMinutes / MinutesInHour
                    );
            }
            storage.Update(this);
        }
Example #14
0
        public void MapEFToBOList()
        {
            var          mapper = new DALLessonStatusMapper();
            LessonStatus entity = new LessonStatus();

            entity.SetProperties(1, "A", 1);

            List <BOLessonStatus> response = mapper.MapEFToBO(new List <LessonStatus>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Example #15
0
        /// <summary> Insert a user status into the UserQuizStatus table </summary>
        public static void InsertLessonStatus(int userID, int moduleID, LessonStatus lessonStatus)
        {
            string sqlInsertLesson = @"
									INSERT into tblUserLessonStatus (UserID, ModuleID, LessonStatusID)
									VALUES(@UserID, @ModuleID, @LessonStatusID)
									"                                    ;

            System.Data.SqlClient.SqlParameter[] sqlParams =
            {
                new SqlParameter("@userID",         userID),
                new SqlParameter("@ModuleID",       moduleID),
                new SqlParameter("@LessonStatusID", (int)Enum.Parse(typeof(LessonStatus), lessonStatus.ToString()))
            };

            string connectionString = ConfigurationSettings.AppSettings["ConnectionString"] + "password="******"password"] + ";";

            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(connectionString, System.Data.CommandType.Text, sqlInsertLesson, sqlParams);
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <ILessonStatusRepository>();
            var record = new LessonStatus();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new LessonStatusService(mock.LoggerMock.Object,
                                                  mock.RepositoryMock.Object,
                                                  mock.ModelValidatorMockFactory.LessonStatusModelValidatorMock.Object,
                                                  mock.BOLMapperMockFactory.BOLLessonStatusMapperMock,
                                                  mock.DALMapperMockFactory.DALLessonStatusMapperMock,
                                                  mock.BOLMapperMockFactory.BOLLessonMapperMock,
                                                  mock.DALMapperMockFactory.DALLessonMapperMock);

            ApiLessonStatusResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Example #17
0
        private static void InitializeLessonStatuses(KorepetycjeContext context)
        {
            if (context.LessonStatuses.Any())
            {
                return;
            }

            var lessonStatusesIds = Enum.GetValues(typeof(LessonStatuses)).Cast <int>().ToList();

            foreach (var statusId in lessonStatusesIds)
            {
                var statusName   = ((LessonStatuses)statusId).ToString();
                var lessonStatus = new LessonStatus
                {
                    Name = statusName
                };
                context.LessonStatuses.Add(lessonStatus);
            }
            context.SaveChanges();
        }
Example #18
0
        /// <summary>
        /// Helper function to convert LessonStatus to the RTE string value
        /// </summary>
        public static string GetRteLessonStatus(LessonStatus status)
        {
            switch (status)
            {
            case LessonStatus.Browsed:
                return("browsed");

            case LessonStatus.Completed:
                return("completed");

            case LessonStatus.Failed:
                return("failed");

            case LessonStatus.Incomplete:
                return("incomplete");

            case LessonStatus.Passed:
                return("passed");

            default:     // case LessonStatus.NotAttempted:
                return("not attempted");
            }
        }
Example #19
0
        public async Task <IActionResult> Delete([FromForm] int id)
        {
            try
            {
                if (this.ValidRoleForAction(_context, _auth, new string[] { "Admin" }))
                {
                    LessonStatus item = await _context.GetByIdAsync <LessonStatus>(x => x.Id == id);

                    if (item != null)
                    {
                        _context.Delete(item);
                        bool result = await _context.SaveAll();

                        if (result == true)
                        {
                            return(Ok(item));
                        }
                        else
                        {
                            return(BadRequest("Model cannot be  deleted"));
                        }
                    }
                    else
                    {
                        return(NotFound("Model not found"));
                    }
                }
                return(Forbid());
            }
            catch (Exception ex)
            {
                var arguments = this.GetBaseData(_context, _auth);
                _logger.LogException(ex, arguments.Email, arguments.Path);
                return(BadRequest($"{ex.GetType().Name} was thrown."));
            }
        }
Example #20
0
 /// <summary>
 /// All enum values are valid
 /// </summary>
 /// <param name="value"></param>
 public override void ValidateStatus(LessonStatus? value)
 {
     if(value == null)
     {
         throw new ArgumentNullException("value");
     }
     switch(value.Value)
     {
     case LessonStatus.Browsed:
     case LessonStatus.Completed:
     case LessonStatus.Failed:
     case LessonStatus.Incomplete:
     case LessonStatus.NotAttempted:
     case LessonStatus.Passed:
         break;
     default:
         throw new ArgumentOutOfRangeException("value");
     }
 }
Example #21
0
 /// <summary>
 /// This is invalid for SCORM 2004.
 /// </summary>
 /// <param name="value">The value to validate.</param>
 public override void ValidateStatus(LessonStatus? value)
 {
     throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.OnlyValidForSCORMV1p2, "Status"));
 }
Example #22
0
 public abstract void ValidateStatus(LessonStatus? value);
        public IEnumerable <TViewModel> GetExamsByStatus <TViewModel>(LessonStatus status)
        {
            var exams = this.examRepository.All().Where(x => x.Status == status).ProjectTo <TViewModel>().ToList();

            return(exams);
        }
 /// <summary>
 /// Helper function to convert LessonStatus to the RTE string value
 /// </summary>
 public static string GetRteLessonStatus(LessonStatus status)
 {
     switch (status)
     {
         case LessonStatus.Browsed:
             return "browsed";
         case LessonStatus.Completed:
             return "completed";
         case LessonStatus.Failed:
             return "failed";
         case LessonStatus.Incomplete:
             return "incomplete";
         case LessonStatus.Passed:
             return "passed";
         default: // case LessonStatus.NotAttempted:
             return "not attempted";
     }
 }