public AvailableCourseViewModel(AvailableCourse course) : base(course) { Brand = course.Brand; Category = course.Category; Topic = course.Topic; DelegateStatus = (DelegateStatus)course.DelegateStatus; EnrolButtonText = GetEnrolButtonText(DelegateStatus); EnrolButtonAriaLabel = EnrolButtonText == null ? null : $"{EnrolButtonText} on activity"; }
public void Available_course_should_map_delegate_status( int delegateStatus, DelegateStatus expectedMappedDelegateStatus ) { // Given var availableCourse = AvailableCourseHelper.CreateDefaultAvailableCourse(delegateStatus: delegateStatus); // When var availableCourseViewModel = new AvailableCourseViewModel(availableCourse); // Then availableCourseViewModel.DelegateStatus.Should().Be(expectedMappedDelegateStatus); }
public IHttpActionResult ChangeDelegateState(string userName, string trustedUserName, DelegateStatus state) { try { if (userName == null || userName.Length == 0 || trustedUserName == null || trustedUserName.Length == 0) { return(BadRequest("The supplied username(s) are invalid")); } else { Models.Delegate delegates = db.Delegates.Where(d => (d.UserName == userName && d.TrustedUser == trustedUserName) || (d.TrustedUser == userName && d.UserName == trustedUserName)).FirstOrDefault(); if (delegates == null) { return(BadRequest("The trusted zone relationship does not yet exist")); } else if (delegates.Status == DelegateStatus.Rejected) { return(BadRequest("The trusted zone is in rejected state, hence state cannot be changed")); } else if (delegates.Status == DelegateStatus.Accepted && state == DelegateStatus.Pending) { return(BadRequest("The trusted zone is in accepted state, hence can't change back to pending")); } else { delegates.Status = state; db.SaveChanges(); return(Ok()); } } } catch (Exception e) { string sSource; string sLog; sSource = "Smart Printer Service"; sLog = "Application"; if (!EventLog.SourceExists(sSource)) { EventLog.CreateEventSource(sSource, sLog); } string errorMessage = e.Message + "\n\n"; while (e.InnerException != null) { errorMessage += e.InnerException + "\n"; e = e.InnerException; } EventLog.WriteEntry(sSource, errorMessage, EventLogEntryType.Error); return(InternalServerError()); } }
/// <summary> /// Executes the query and returns all registered delegates with the specified status /// </summary> /// <param name="status">Status of the delegates to return</param> /// <returns></returns> public Task <T> GetAsync <T>(DelegateStatus status) => Client.GetJson <T>($"{Query}?{status.ToString().ToLower()}");
/// <summary> /// Executes the query and returns all registered delegates with the specified status /// </summary> /// <param name="status">Status of the delegates to return</param> /// <returns></returns> public Task <JToken> GetAsync(DelegateStatus status) => Client.GetJson($"{Query}?{status.ToString().ToLower()}");
/// <summary> /// Executes the query and returns all registered delegates with the specified status /// </summary> /// <param name="status">Status of the delegates to return</param> /// <returns></returns> public Task <dynamic> GetAsync(DelegateStatus status) => Client.GetJson($"{Query}?{status.ToString().ToLower()}=true");
private static string?GetEnrolButtonText(DelegateStatus delegateStatus) => delegateStatus switch {