예제 #1
0
        public IActionResult LogIn(User _user)
        {
            var functions = new functions();
            var user      = _context.Users.SingleOrDefault(u => u.StundetId == _user.StundetId);

            if (user != null)
            {
                if (functions.CheckPassword(_user.Password, user.Password))
                {
                    string s = _user.StundetId.ToString();
                    string a = user.Authorization.ToString();
                    HttpContext.Session.SetString("Aut", a);
                    HttpContext.Session.SetString("User", s);

                    return(RedirectToAction("Wellcome", "Home"));
                }
                else
                {
                    ViewBag.Message  = "Thank you!";
                    TempData["msg2"] = "<script>alert('סיסמה שגויה');</script>";
                }
            }
            else
            {
                TempData["msg1"] = "<script>alert('ת.ז לא נמצאה במערכת');</script>";
            }
            return(View());
        }
        // GET: ApprovalKits/Edit/5
        //get id of approval kit and reurnt is details to edit form
        public async Task <IActionResult> Edit(int?id)
        {
            var functions = new functions();

            if (functions.Comper(new DateTime(2019, 9, 5)))
            {
                string Aut = HttpContext.Session.GetString("Aut");
                ViewBag.Aut = Aut;
                string Id = HttpContext.Session.GetString("User");
                if (id == null)
                {
                    return(NotFound());
                }

                var approvalKit = await _context.ApprovalKits.SingleOrDefaultAsync(m => m.ID == id);

                if (Aut.Equals("2") || Id.Equals(approvalKit.StundetId.ToString()))
                {
                    //var approvalKit = await _context.ApprovalKits.SingleOrDefaultAsync(m => m.ID == id);
                    if (approvalKit == null)
                    {
                        return(NotFound());
                    }
                    return(View(approvalKit));
                }
                return(RedirectToAction("NotAut", "Home"));
            }
            return(RedirectToAction("NoMore", "Home"));
        }
        public async Task <IActionResult> Create([Bind("StundetId,LastName,FirstName,RoomType,LivingWithReligious,LivingWithSmoker,ReligiousType,HealthCondition,PartnerId1,PartnerId2,PartnerId3,PartnerId4")] ApprovalKit approvalKit)
        {
            var functions = new functions();

            if (functions.Comper(new DateTime(2019, 9, 5)))
            {
                string Aut = HttpContext.Session.GetString("Aut");
                ViewBag.Aut = Aut;
                string Id = HttpContext.Session.GetString("User");
                var    u  = await _context.Registrations.SingleOrDefaultAsync(m => m.StundetId.ToString().Equals(Id));

                approvalKit.FirstName = u.FirstName;
                approvalKit.LastName  = u.LastName;
                approvalKit.StundetId = u.StundetId;
                approvalKit.Gender    = u.gender;
                try
                {
                    if (ModelState.IsValid)
                    {
                        //u.Authorization = 9;
                        _context.Add(approvalKit);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction("Wellcome", "Home"));
                    }
                }
                catch (DbUpdateException)
                {
                    ModelState.AddModelError("", "לא היה ניתן לשמור את השינויים, נא נסה שנית במועד מאוחר יותר");
                }
                return(View(approvalKit));
            }
            return(RedirectToAction("NoMore", "Home"));
        }
예제 #4
0
        // return a list of fiels that the user uplouad
        public async Task <IActionResult> SeeFiles(int student)
        {
            string Aut = HttpContext.Session.GetString("Aut");

            ViewBag.Aut = Aut;
            var    userId    = HttpContext.Session.GetString("User");
            string studentId = "";

            if (student == null)
            {
                studentId = userId;
            }
            else
            {
                studentId = student.ToString();
            }

            var functions = new functions();
            var u         = await _context.Registrations.SingleOrDefaultAsync(m => m.StundetId.ToString().Equals(studentId));

            if (functions.Comper(new DateTime(2019, 7, 30)))
            {
                if (Aut.Equals("2") || userId.Equals(u.StundetId.ToString()))
                {
                    if (!Directory.Exists(Path.Combine(
                                              Directory.GetCurrentDirectory(), $"wwwroot/{studentId}")))
                    {
                        return(RedirectToAction("NoFiles", "Home"));
                    }
                    string[]      filePaths = Directory.GetFiles(@"wwwroot\" + studentId);
                    List <string> list      = new List <string> {
                    };
                    foreach (var file in filePaths)
                    {
                        string s = file.Substring(8);


                        list.Add(s);
                    }
                    ViewBag.url = list;
                    return(View());
                }
            }
            return(RedirectToAction("NotAut", "Home"));
        }
예제 #5
0
        // confirm the user idntitiy and change the record
        public async Task <ActionResult> ConifiremSigniture(int id, int StudentId, string password)
        {
            string Aut = HttpContext.Session.GetString("Aut");

            ViewBag.Aut = Aut;
            string Id = HttpContext.Session.GetString("User");
            //user by session
            var u = await _context.Users.SingleOrDefaultAsync(m => m.StundetId.ToString().Equals(Id));


            ViewBag.StudentId = StudentId;
            var functions = new functions();
            //user by StudentId
            var visitorsLog = await _context.VisitorsLogs.SingleOrDefaultAsync(m => m.Id == id);

            var user = await _context.Users.SingleOrDefaultAsync(m => m.StundetId == StudentId);

            if (user != null)
            {
                if (functions.CheckPassword(password, user.Password))
                {
                    visitorsLog.Signature = true;
                    _context.Update(visitorsLog);
                    await _context.SaveChangesAsync();

                    return(View());
                }
                else
                {
                    ViewBag.Message = "Thank you!";
                    TempData["msg"] = "<script>alert('הסיסמה שגויה');</script>";

                    return(RedirectToAction(nameof(Signature), new { id = visitorsLog.Id }));
                }
            }
            TempData["msg"] = "<script>alert('הת.ז שהוזנה לא תואמת את הת.ז של המשתמש');</script>";

            return(RedirectToAction(nameof(Signature), new { id = visitorsLog.Id }));
        }