Esempio n. 1
0
        public int CreateStuClassroom(StudentClassroom item)
        {
            _context.StudentClassroom.Add(item);
            _context.SaveChanges();

            return(item.StudentClassroomID);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,StudentId,ClassroomId")] StudentClassroom studentClassroom)
        {
            if (id != studentClassroom.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentClassroom);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentClassroomExists(studentClassroom.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassroomId"] = new SelectList(_context.Classrooms, "Id", "Id", studentClassroom.ClassroomId);
            return(View(studentClassroom));
        }
Esempio n. 3
0
        public JsonResult RegisterByDeskTop(Register model)
        {
            UserModule             module      = new UserModule(_context, _userManager, _signInManager);
            ParentModule           parentMod   = new ParentModule(_context);
            StudentModule          studentMod  = new StudentModule(_context);
            StudentParentModule    stuParMod   = new StudentParentModule(_context);
            StudentClassroomModule stuClassMod = new StudentClassroomModule(_context);

            //=========== checking validation for credencials key ===============//
            var credInfo = GetCredentialsInfo(model.Student.Key);

//           if ( GetCredentialsInfo(model.Student.Key) == null )
            if (credInfo == null)
            {
                return(Json(new { Succeeded = false, statusCode = 501 }));
            }

            var resultVal = module.CreateUserByDeskTop(model.Users);

            if (resultVal.Result.StatusCode == 200)     // success Users table
            {
                if (module.GetUserInfo(model.Users) != null)
                {
                    Users user = new Users {
                        UserName = model.Users.Email, PasswordHash = model.Users.PasswordHash
                    };

                    string oauthResult = CreateOAuthUser(user);  // need validation check. if result is success return success value else delete MPXUser data and return error.

                    if (model.Parent == null)
                    {
                        model.Parent = new Parent();
                    }
                    model.Parent.UserId = module.GetUserInfo(model.Users).Id;     //select userID
                    int parentID = parentMod.CreateParent(model.Parent);          //save parent info
                    model.Student.ParentID = parentID;
                    int studentID = studentMod.CreateStudent(model.Student);      //save student info

                    StudentParent stuParModel = new StudentParent {
                        ParentID = parentID, StudentID = studentID
                    };

                    stuParMod.CreateStudentParent(stuParModel);     //save StudentParent info
                    StudentClassroom stuClassModel = new StudentClassroom {
                        StudentID = studentID, IsActive = true, ClassroomID = credInfo.Teacher.ClassroomID
                    };

                    stuClassMod.CreateStuClassroom(stuClassModel);      //save studentclassroom
//                    var roleresult = _userManager.AddToRoleAsync(model.Users, "Superusers");
                }
            }

            return(Json(resultVal.Result));
        }
        public async Task <IActionResult> Create([Bind("Id,Description,ClassroomId")] StudentClassroom studentClassroom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studentClassroom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassroomId"] = new SelectList(_context.Classrooms, "Id", "Id", studentClassroom.ClassroomId);
            return(View(studentClassroom));
        }
Esempio n. 5
0
        public CommonResponce Delete(StudentClassroom StudentClassroomToDelete)
        {
            CommonResponce result  = new CommonResponce();
            bool           isValid = false;

            try
            {
                _commonRepository.Delete(_mapper.Map <Tblrstudentclassroom>(StudentClassroomToDelete));
                result.Stat      = true;
                result.StatusMsg = "Student assignment to Classroom deleted successfully";
            }
            catch { result.Stat = isValid; result.StatusMsg = "Failed to delete Student assignment to Classroom"; }
            return(result);
        }
Esempio n. 6
0
        public async Task <CommonResponce> Insert(StudentClassroom StudentClassroomToInsert)
        {
            CommonResponce result  = new CommonResponce();
            bool           isValid = false;

            try
            {
                isValid = await _commonRepository.Insert(_mapper.Map <Tblrstudentclassroom>(StudentClassroomToInsert));

                result.Stat      = isValid;
                result.StatusMsg = "Student assigned to Classroom successfully";
            }
            catch (Exception ex) { result.Stat = isValid; result.StatusMsg = ex.Message + " Failed to assign Student to Classroom"; }
            return(result);
        }
        public async Task <IActionResult> Create(StudentClassroomViewModel model)
        {
            var currentUser      = _context.Users.FirstOrDefault(u => u.UserName == User.Identity.Name);
            var studentClassroom = new StudentClassroom()
            {
                Description         = model.Description,
                Classroom           = _context.Classrooms.Find(model.ClassroomId),
                Student             = currentUser,
                StudentMarks        = new List <Mark>(),
                StudentDayOfClasses = new List <DayOfClass>()
            };

            if (ModelState.IsValid)
            {
                _context.Add(studentClassroom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClassroomId"] = new SelectList(_context.Classrooms, "Id", "Id", studentClassroom.ClassroomId);
            return(View(model));
        }