예제 #1
0
 void Awake()
 {
     instance          = this;
     m_fadeImage.color = new Color(0, 0, 0, 1);
     isStart.onValueChanged.AddListener((bool value) => OnStartGame(value));
     m_skipButton.onClick.AddListener(LoadScene);
 }
예제 #2
0
        public IEnumerable<Lecture> GetByTutor()
        {
            string tutorId = User.Identity.GetUserId();
            if (tutorId == null)
                throw new HttpResponseException(HttpStatusCode.NotFound);

            var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
            IEnumerable<Lecture> AllLectures = tutorManager.GetAllLecturesByTutorId(tutorId);
            return AllLectures;
        }
예제 #3
0
    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("SingleTone Error!");
            Destroy(gameObject);
            return;
        }

        instance = this;
    }
예제 #4
0
        public HttpResponseMessage GetFile(string fileid)
        {
            var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
            var path = tutorManager.GetFilePath(fileid);
            var namePos = path.LastIndexOf('\\') + 1;
            var prefileName = path.Substring(namePos);
            var fileName = ConvertUTF8ToIso(prefileName);
            if (!File.Exists(path))
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Can't load file"));

            var result = new HttpResponseMessage(HttpStatusCode.OK);
            var stream = new FileStream(path, FileMode.Open);

            result.Content = new StreamContent(stream);
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
            result.Content.Headers.ContentDisposition.FileName = fileName;



            //result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/odt");
            return result;
        }
예제 #5
0
        public IEnumerable<Lecture> GetByDiscipline()
        {
            var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
            IEnumerable<Lecture> AllLectures = tutorManager.GetAllLectures();

            //if (orderby == "bydate")
            //{
            //    result = LectureTests
            //        .Where(l => l.Discipline == discipline)
            //        .OrderBy(l => l.Date)
            //        .Skip((page - 1) * itemsperpage)
            //        .Take(itemsperpage);
            //}
            //else if (orderby == "bydiscipline")
            //{
            //    result = LectureTests
            //        .Where(l => l.Discipline == discipline)
            //        .OrderBy(l => l.Discipline)
            //        .Skip((page - 1) * itemsperpage)
            //        .Take(itemsperpage);
            //}

            return AllLectures;
        }
예제 #6
0
 public void Delete(string lectureId)
 {
     var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
     tutorManager.DeleteLecture(lectureId);
 }
예제 #7
0
        public async Task<HttpResponseMessage> Put(string lectureId)
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            string root = HttpContext.Current.Server.MapPath("~/App_Data");
            var provider = new CustomMultipartFormDataStreamProvider(root);


            try
            {
                await Request.Content.ReadAsMultipartAsync(provider);

                string pathToFile = provider.FileData.FirstOrDefault()?.LocalFileName;
                if (pathToFile == null)
                    pathToFile = "NULL";
                string subject = provider.FormData["subject"];
                string LectureName = provider.FormData["name"];
                var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
                tutorManager.UpdateLecture(new Lecture()
                {
                    LectureId = lectureId,
                    FilePath = pathToFile,
                    Subject = subject,
                    LectureText = LectureName,                    
                });

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
        }
예제 #8
0
 public  async Task<IHttpActionResult> ActivateTutor([FromBody]TutorToActivate tutor)
 {
     var tutorManager =
         new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
     tutorManager.ActivateTutor(tutor.TutorId);
     return Ok();
 }
예제 #9
0
        public async Task<IEnumerable<RequestInfo>> GetTutorRequests()
        {
            var tutorManager = 
                new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));

            var result = await tutorManager.GetRequestInfo();
            return result;
        }
예제 #10
0
        public HttpResponseMessage GetById(string id)
        {
            var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
            Lecture result = tutorManager.GetLectureInfoById(id);
            if (result != null)
                return Request.CreateResponse<Lecture>(HttpStatusCode.OK,result);

            return Request.CreateResponse(HttpStatusCode.NotFound);            
        }
예제 #11
0
        public IEnumerable<string> GetDisciplines()
        {
            var tutorManager = new TutorManager<TutorRequestStore, TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
            IEnumerable<string> result = tutorManager.GetAllDisciplines();


            return result;

        }
예제 #12
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));
                var user = new AppUser { UserName = model.Email, Email = model.Email };
                if (model.AppRole == Role.Student)
                {
                    string role = Role.Student.ToString();

                    //adding new client as student
                    if (!roleManager.RoleExists(role))
                    {
                        roleManager.Create(new IdentityRole(role));
                    }

                    var result = await UserManager.CreateAsync(user, model.Password);
                    if (result.Succeeded)
                    {
                        UserManager.AddToRole(user.Id, role);
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                        // Send an email with this link
                        // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                        // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                        return RedirectToAction("StudentIndex", "Home");
                    }

                    AddErrors(result);
                }
                else if (model.AppRole == Role.Tutor)
                {
                    string role = Role.Tutor.ToString();
                    if (!roleManager.RoleExists(role))
                    {
                        roleManager.Create(new IdentityRole(role));
                    }

                    var result = await UserManager.CreateAsync(user, model.Password);
                    if (result.Succeeded)
                    {
                        var tutorRequestManager = new TutorManager<TutorRequestStore,TutorRequest>(new TutorRequestStore(new ApplicationDbContext()));
                        await tutorRequestManager.AddTutorRequest(new TutorRequest() {
                            RequesterId = user.Id,
                            RequestId = Guid.NewGuid().ToString()
                        });
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        return View("TutorInvitation");
                    }

                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);

        }