public MentorRepository(
     MentorContext context,
     UserManager <MODUser> userManager,
     RoleManager <IdentityRole> roleManager)
 {
     this.context     = context;
     this.userManager = userManager;
     this.roleManager = roleManager;
 }
예제 #2
0
        public async Task <ActionResult <Mentor> > GetMentor(int id)
        {
            MentorContext context       = HttpContext.RequestServices.GetService(typeof(MentorContext)) as MentorContext;
            Mentor        mentorDetails = context.GetMentorById(id);

            if (mentorDetails == null)
            {
                return(NoContent());
            }
            return(Ok(mentorDetails));
        }
예제 #3
0
        public async Task <ActionResult <IEnumerable <Mentor> > > GetMentors()
        {
            MentorContext context        = HttpContext.RequestServices.GetService(typeof(MentorContext)) as MentorContext;
            List <Mentor> mentorsDetails = context.GetAllMentors();

            if (mentorsDetails == null || mentorsDetails.Count == 0)
            {
                return(NoContent());
            }
            return(Ok(mentorsDetails));
        }
예제 #4
0
 public MentorRepository(MentorContext context)
 {
     this.context = context;
 }
예제 #5
0
        public async Task <ActionResult <Mentor> > DeleteMentor(int id)
        {
            MentorContext context = HttpContext.RequestServices.GetService(typeof(MentorContext)) as MentorContext;

            return(Ok(context.DeleteMentorById(id)));
        }
예제 #6
0
        public async Task <ActionResult <bool> > PostMentor(Mentor mentor)
        {
            MentorContext context = HttpContext.RequestServices.GetService(typeof(MentorContext)) as MentorContext;

            return(Ok(context.AddMentor(mentor)));
        }
예제 #7
0
 public MentorsController(MentorContext context)
 {
     _context = context;
 }