Ejemplo n.º 1
0
        public ApiResult <TrainFaceModel> TrainStudentFaceByImageUpload()
        {
            var            r = new ApiResult <TrainFaceModel>();
            TrainFaceModel trainFaceModel = new TrainFaceModel();
            var            httpRequest    = System.Web.HttpContext.Current.Request;

            if (httpRequest.Files.Count < 1)
            {
                r.Messages.Add("Vui lòng upload ảnh");
            }
            else if (httpRequest.Files.Count > 1)
            {
                r.Messages.Add("Vui lòng chỉ uplaod 1 ảnh duy nhât");
            }
            else
            {
                HttpPostedFile file = httpRequest.Files[0];
                byte[]         thePictureAsBytes = new byte[file.ContentLength];
                using (BinaryReader theReader = new BinaryReader(file.InputStream))
                {
                    thePictureAsBytes = theReader.ReadBytes(file.ContentLength);
                }
                trainFaceModel.StudentId   = Int32.Parse(httpRequest.Files.AllKeys[0]);
                trainFaceModel.Base64Image = Convert.ToBase64String(thePictureAsBytes);
                r = RCSService.TrainStudentFace(trainFaceModel);
            }
            return(r);
        }
        public ApiResult <RollCallReponseModel> RollCallByImageUpload()
        {
            var           r             = new ApiResult <RollCallReponseModel>();
            RollCallModel rollCallModel = new RollCallModel();
            var           httpRequest   = System.Web.HttpContext.Current.Request;

            if (httpRequest.Files.Count < 1)
            {
                r.Messages.Add("Vui lòng upload ảnh");
            }
            else if (httpRequest.Files.Count > 1)
            {
                r.Messages.Add("Vui lòng chỉ uplaod 1 ảnh duy nhât");
            }
            else
            {
                HttpPostedFile file = httpRequest.Files[0];
                byte[]         thePictureAsBytes = new byte[file.ContentLength];
                using (BinaryReader theReader = new BinaryReader(file.InputStream))
                {
                    thePictureAsBytes = theReader.ReadBytes(file.ContentLength);
                }
                rollCallModel.ClassScheduleId = Int32.Parse(httpRequest.Files.AllKeys[0]);
                rollCallModel.Base64Image     = Convert.ToBase64String(thePictureAsBytes);
                r = RCSService.RollCall(rollCallModel);
            }
            return(r);
        }
        public ApiResult <User> CheckLogin()
        {
            var apiResult = new ApiResult <User>();

            if (ClaimsPrincipal.Current.Identity.IsAuthenticated == true)
            {
                apiResult = RCSService.GetCurrentUser();
            }
            else
            {
                apiResult.IsSuccess = false;
            }
            return(apiResult);
        }
        public ApiResult <User> Login(LoginModel login)
        {
            var apiResult = RCSService.Login(login);

            if (apiResult.IsSuccess)
            {
                var claims = new List <Claim>();
                claims.Add(new Claim(ClaimTypes.NameIdentifier, apiResult.Data.Id.ToString()));
                claims.Add(new Claim(ClaimTypes.Role, apiResult.Data.Role.ToString()));
                var userIdentity = new UserIdentity()
                {
                    AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
                    IsAuthenticated    = true
                };
                var claimIdentity = new ClaimsIdentity(userIdentity, claims);
                AuthenticationManager.SignIn(claimIdentity);
            }
            return(apiResult);
        }
 public HttpResponseMessage GetClassReport(int classId)
 {
     return(RCSService.GetClassReport(classId));
 }
 public ApiResult <int> DeleteFile(int fileId)
 {
     return(RCSService.DeleteFile(fileId));
 }
Ejemplo n.º 7
0
 public ApiResult <TrainFaceModel> TrainStudentFace(TrainFaceModel model)
 {
     return(RCSService.TrainStudentFace(model));
 }
 public ApiResult <ClassSchedule> CloseClass(int classScheduleId)
 {
     return(RCSService.CloseClass(classScheduleId));
 }
 public ApiResult <List <User> > CreateAccount(List <UserCreateModel> newUsers)
 {
     return(RCSService.CreateAccount(newUsers));
 }
 public ApiResult <Class> GetClass(int classId)
 {
     return(RCSService.GetClass(classId));
 }
 public ApiResult <Teacher> GetTeacherInfo(int teacherId)
 {
     return(RCSService.GetTeacherInfo(teacherId));
 }
 public ApiResult <List <Class> > GetAllClassByTeacherId(ClassSeachModel seachModel)
 {
     return(RCSService.GetAllClassByTeacherId(seachModel));
 }
Ejemplo n.º 13
0
 public ApiResult <List <TrainingImage> > GetStudentTrainImages(int studentId)
 {
     return(RCSService.GetStudentTrainImages(studentId));
 }
Ejemplo n.º 14
0
 public ApiResult <Student> GetStudentInfo(int studentId)
 {
     return(RCSService.GetStudentInfo(studentId));
 }
Ejemplo n.º 15
0
 public ApiResult <List <Studying> > GetAllSubject(int studentId)
 {
     return(RCSService.GetAllSubject(studentId));
 }
 public ApiResult <ClassSchedule> UpdateClassSchedule(ClassSchedule classSchedule)
 {
     return(RCSService.UpdateClassSchedule(classSchedule));
 }
 public ApiResult <User> GetCurrentUser()
 {
     return(RCSService.GetCurrentUser());
 }
 public ApiResult <RollCall> ChangeRollCall(int classScheduleId, int studentId)
 {
     return(RCSService.ChangeRollCall(classScheduleId, studentId));
 }
 public ApiResult <RollCallReponseModel> RollCall(RollCallModel model)
 {
     return(RCSService.RollCall(model));
 }
 public BaseApiController()
 {
     RCSService = new RCSService();
 }
 public ApiResult <ClassSchedule> OpenClass(int classScheduleId)
 {
     return(RCSService.OpenClass(classScheduleId));
 }
 public HttpResponseMessage GetFileDataById(int fileId)
 {
     return(RCSService.GetFileDataById(fileId));
 }
 public ApiResult <ClassSchedule> GetClassScheduleFullData(int classScheduleId)
 {
     return(RCSService.GetClassScheduleFullData(classScheduleId));
 }
Ejemplo n.º 24
0
 public ApiResult <List <Student> > GetAllStudent()
 {
     return(RCSService.GetAllStudent());
 }