Exemplo n.º 1
0
 public override string[] GetAllRoles()
 {
     using (var LMSContext = new LMSContext())
     {
         return(LMSContext.Roles.Select(r => r.RoleName).ToArray());
     }
 }
Exemplo n.º 2
0
 public DashboardController(LMSContext context, UserManager <User> userManager, SignInManager <User> signInManager, RoleManager <IdentityRole> roleManager)
 {
     this.context       = context;
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.roleManager   = roleManager;
 }
        public ActionResult AddOrEditAttendance(Attendance attendance)
        {
            using (LMSContext db = new LMSContext())
            {
                if (attendance.ID == 0)
                {
                    var newAtendance = new Attendance();
                    newAtendance.Date   = DateTime.Now;
                    newAtendance.Remark = "test";

                    var student = db.Students.ToList().FirstOrDefault();
                    newAtendance.Student = student;

                    db.Attendances.Add(newAtendance);
                    db.SaveChanges();
                    return(Json(new { success = true, message = "Записът е успешен." }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    db.Entry(attendance).State = EntityState.Modified;
                    db.SaveChanges();
                    return(Json(new { success = true, message = "Редакцията е успешна." }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 4
0
 public UserService(LMSContext context,
                    IBanService banService
                    )
 {
     _context    = context;
     _banService = banService;
 }
 public MembershipService(LMSContext context,
                          IUserService userservice,
                          UserManager <User> userMng)
 {
     _context     = context;
     _userservice = userservice;
     _userMng     = userMng;
 }
 public ActionResult GetDataAttendance()
 {
     using (LMSContext db = new LMSContext())
     {
         List <Attendance> attend = db.Attendances.ToList <Attendance>();
         return(Json(new { data = attend }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetDataLevel()
 {
     using (LMSContext db = new LMSContext())
     {
         List <Level> levelList = db.Levels.ToList <Level>();
         return(Json(new { data = levelList }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetDataArea()
 {
     using (LMSContext db = new LMSContext())
     {
         List <Area> areasList = db.Areas.ToList <Area>();
         return(Json(new { data = areasList }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GetDataCource()
 {
     using (LMSContext db = new LMSContext())
     {
         List <Cource> courseList = db.Cources.ToList <Cource>();
         return(Json(new { data = courseList }, JsonRequestBehavior.AllowGet));
     }
 }
 public AccountController(UserManager <User> userManager, RoleManager <IdentityRole> roleManager, SignInManager <User> signInManager, LMSContext context)
 {
     _queries           = new Queries(context, userManager);
     this.userManager   = userManager;
     this.roleManager   = roleManager;
     this.signInManager = signInManager;
     this.context       = context;
 }
 public ActionResult GetDataGradeParallel()
 {
     using (LMSContext db = new LMSContext())
     {
         List <GradeParallel> grdpList = db.GradeParallels.ToList <GradeParallel>();
         return(Json(new { data = grdpList }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 12
0
 public BookService(LMSContext context,
                    IAuthorService authorService,
                    ISubjectCategoryService subject)
 {
     _context        = context ?? throw new ArgumentNullException(nameof(context));
     _authorService  = authorService ?? throw new ArgumentNullException(nameof(authorService));
     _subjectService = subject ?? throw new ArgumentNullException(nameof(subject));
 }
 public ActionResult GetDataSubjectGrade()
 {
     using (LMSContext db = new LMSContext())
     {
         List <SubjectGrade> subgrdList = db.SubjectGrades.ToList <SubjectGrade>();
         return(Json(new { data = subgrdList }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 14
0
 public ActionResult GetData()
 {
     using (LMSContext db = new LMSContext())
     {
         List <Student> stList = db.Students.ToList <Student>();
         return(Json(new { data = stList }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteAttendance(int id)
 {
     using (LMSContext db = new LMSContext())
     {
         Attendance attendance = db.Attendances.Where(x => x.ID == id).FirstOrDefault <Attendance>();
         db.Attendances.Remove(attendance);
         db.SaveChanges();
         return(Json(new { success = true, message = "Записът е изтрит." }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult DeleteSubjectGrade(int id)
 {
     using (LMSContext db = new LMSContext())
     {
         SubjectGrade subgr = db.SubjectGrades.Where(x => x.ID == id).FirstOrDefault <SubjectGrade>();
         db.SubjectGrades.Remove(subgr);
         db.SaveChanges();
         return(Json(new { success = true, message = "Записът е изтрит." }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 17
0
        // GET: LMS
        public ActionResult Index()
        {
            LMSContext context = new LMSContext();

            //context.Database.Initialize(true);
            //context.Students.Add(new Student() { FirstName = "Георги", LastName = "Георгиев" });
            //context.SaveChanges();

            return(View());
        }
 public ActionResult DeleteGradeParallel(int id)
 {
     using (LMSContext db = new LMSContext())
     {
         GradeParallel grd = db.GradeParallels.Where(x => x.ID == id).FirstOrDefault <GradeParallel>();
         db.GradeParallels.Remove(grd);
         db.SaveChanges();
         return(Json(new { success = true, message = "Записът е изтрит." }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 19
0
        public void Throw_WhenTheContextIsNull()
        {
            // Arrange
            var options = TestUtilities.GetOptions(MethodBase.GetCurrentMethod().Name);

            using (var assertContext = new LMSContext(options))
            {
                // Act && Assert
                Assert.ThrowsException <ArgumentNullException>(() => new AuthorService(null));
            }
        }
Exemplo n.º 20
0
 public override bool IsUserInRole(string username, string roleName)
 {
     using (var LMSContext = new LMSContext())
     {
         var user = LMSContext.Users.SingleOrDefault(u => u.UserName == username);
         if (user == null)
         {
             return(false);
         }
         return(user.Roles != null && user.Roles.Any(r => r.RoleName == roleName));
     }
 }
Exemplo n.º 21
0
 public override string[] GetRolesForUser(string username)
 {
     using (var LMSContext = new LMSContext())
     {
         var user = LMSContext.Users.SingleOrDefault(u => u.UserName == username);
         if (user == null)
         {
             return new string[] {}
         }
         ;
         return(user.Roles == null ? new string[] { } : user.Roles.Select(u => u.RoleName).ToArray());
     }
 }
Exemplo n.º 22
0
        public void Throw_WhenSubjectServiceIsNull()
        {
            // Assert
            var options            = TestUtilities.GetOptions(MethodBase.GetCurrentMethod().Name);
            var mockAuthorService  = new Mock <IAuthorService>();
            var mockSubjectService = new Mock <ISubjectCategoryService>();

            using (var assertContext = new LMSContext(options))
            {
                // Act && Assert
                Assert.ThrowsException <ArgumentNullException>(() => new BookService(assertContext, mockAuthorService.Object, null));
            }
        }
 public ActionResult AddOrEditSubjectGrade(int id = 0)
 {
     if (id == 0)
     {
         return(View(new SubjectGrade()));
     }
     else
     {
         using (LMSContext db = new LMSContext())
         {
             return(View(db.SubjectGrades.Where(x => x.ID == id).FirstOrDefault <SubjectGrade>()));
         }
     }
 }
Exemplo n.º 24
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         return(View(new Student()));
     }
     else
     {
         using (LMSContext db = new LMSContext())
         {
             return(View(db.Students.Where(x => x.ID == id).FirstOrDefault <Student>()));
         }
     }
 }
 public ActionResult AddOrEditGradeParallel(int id = 0)
 {
     if (id == 0)
     {
         return(View(new GradeParallel()));
     }
     else
     {
         using (LMSContext db = new LMSContext())
         {
             return(View(db.GradeParallels.Where(x => x.ID == id).FirstOrDefault <GradeParallel>()));
         }
     }
 }
Exemplo n.º 26
0
        public void Constructor_CreatesInstance()
        {
            // Arrange
            var options = TestUtilities.GetOptions(MethodBase.GetCurrentMethod().Name);

            using (var assertContext = new LMSContext(options))
            {
                // Act
                var sut = new AuthorService(assertContext);

                // Assert
                Assert.IsNotNull(sut);
            }
        }
 public ActionResult AddOrEditAttendance(int id = 0)
 {
     if (id == 0)
     {
         return(View(new Attendance()));
     }
     else
     {
         using (LMSContext db = new LMSContext())
         {
             return(View(db.Attendances.Where(x => x.ID == id).FirstOrDefault <Attendance>()));
         }
     }
 }
Exemplo n.º 28
0
 public bool checkUniqueMobile(string mobileNo)
 {
     using (LMSContext entity = new LMSContext())
     {
         int cnt = entity.AspNetUsers.Where(w => w.PhoneNumber == mobileNo).Count();
         if (cnt > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 29
0
        public void Constructor_CreateInstance()
        {
            // Assert
            var options            = TestUtilities.GetOptions(MethodBase.GetCurrentMethod().Name);
            var mockAuthorService  = new Mock <IAuthorService>();
            var mockSubjectService = new Mock <ISubjectCategoryService>();

            using (var assertContext = new LMSContext(options))
            {
                // Act
                var sut = new BookService(assertContext, mockAuthorService.Object, mockSubjectService.Object);

                // Assert
                Assert.IsNotNull(sut);
            }
        }
 public ActionResult AddOrEditSubjectGrade(SubjectGrade subgr)
 {
     using (LMSContext db = new LMSContext())
     {
         if (subgr.ID == 0)
         {
             db.SubjectGrades.Add(subgr);
             db.SaveChanges();
             return(Json(new { success = true, message = "Записът е успешен." }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(subgr).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Редакцията е успешна." }, JsonRequestBehavior.AllowGet));
         }
     }
 }