コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,dateTime,Message")] StudentLog studentLog)
        {
            if (id != studentLog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentLog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentLogExists(studentLog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentLog));
        }
コード例 #2
0
        public async Task <StudentLog> GetLatestStudentLog(
            int compid,
            int ccode,
            DateTime date)
        {
            var studentLog = new StudentLog();

            try
            {
                var company = GetCurrentCompany();
                compid = company.CompID;

                var dts  = date.ToString("yyyy-MM-dd");
                var url  = $"{serviceAddress}/GetLatestStudentLog/{compid}/{ccode}/{dts}";
                var json = await this.GetAsString(url);

                studentLog = JsonConvert.DeserializeObject <StudentLog>(json, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });
            }
            catch (Exception ex)
            {
                var p = ex.Message;
            }

            return(studentLog);
        }
コード例 #3
0
        public IActionResult SendCode(int Code)
        {
            var log = new StudentLog
            {
                dateTime = DateTime.Now
            };
            Students student = NstudentRepository.GetStudentByCode(Code);

            var webRoot    = _env.WebRootPath;
            var pathToFile = _env.WebRootPath
                             + Path.DirectorySeparatorChar.ToString()
                             + "mail"
                             + Path.DirectorySeparatorChar.ToString()
                             + "RegisterMail.html";
            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
            {
                builder.HtmlBody = SourceReader.ReadToEnd();
            }
            string messageBody = string.Format(builder.HtmlBody, student.FullName, Code, DateTime.Now.ToString("dddd, d MMMM yyyy HH:mm:ss"));


            BackgroundJob.Schedule(() => Reminder(student.Id), TimeSpan.FromDays(1));

            _mail.GenMail(student.email, "Tack för din registrering! ", messageBody);

            // return RedirectToAction("Index", "Home", new { Ncode = student.code });

            log.Message = "New User with email: " + student.email + " Registered and got the code:" + student.code;
            NstudentRepository.AddLog(log);
            return(RedirectToAction("Index", "Home", new { userName = student.email }));
        }
コード例 #4
0
        public async Task <bool> Add(Student _student, StudentLog _studentLog, string password)
        {
            try
            {
                using (var work = new UnitOfWork(new SWEContextFactory().CreateDbContext()))
                {
                    var _studentLogResult = await work.StudentLog.Register(_studentLog, password);

                    _student.StudentLog = _studentLog;

                    await work.Student.Add(_student);

                    await work.Commet();
                }
                if (resultCommet == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch { return(false); }
        }
コード例 #5
0
 public IActionResult LogStudent(StudentLog studentLog)
 {
     if (_service.LogStudent(studentLog))
     {
         return(NotFound("Student Could not Logged successfully please check your input."));
     }
     return(Ok("Student Logged Successfully."));
 }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,dateTime,Message")] StudentLog studentLog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studentLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentLog));
        }
コード例 #7
0
 public bool LogStudent(StudentLog studentLog)
 {
     try
     {
         _repository.InsertLogStudent(studentLog.StudentEmail, studentLog.LogText);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #8
0
        private async void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txt_Id.Text))
            {
                var studentLog = new StudentLog {
                    UserName = txt_UserName.Text
                };
                if (await checkUserNameIsExists(studentLog.UserName))
                {
                    MessageBox.Show("يوجد أسم مستخدم موجود بنفس الاسم برجاء اختيار اسم اخر"); return;
                }

                var student = new Student
                {
                    FullName = txt_FullName.Text,
                    Address  = txt_Address.Text,
                    Leval    = txt_Leval.Text,
                    Phone    = txt_Phone.Text,
                    BDate    = BDate.Value,
                };
                await implementStudent.Add(student, studentLog, txt_Paassword.Text);

                //For Get All Data and Clear Data
                get();
            }
            else
            {
                var studentLog = new StudentLog {
                    UserName = txt_UserName.Text
                };
                if (await checkUserNameIsExists(studentLog.UserName))
                {
                    var student = new Student
                    {
                        Id       = Convert.ToInt32(txt_Id.Text),
                        FullName = txt_FullName.Text,
                        Address  = txt_Address.Text,
                        Leval    = txt_Leval.Text,
                        Phone    = txt_Phone.Text,
                        BDate    = BDate.Value
                    };
                    await implementStudent.Updated(student, studentLog, txt_Paassword.Text);

                    //For Get All Data and Clear Data
                    get();
                }
            }
        }
コード例 #9
0
        //public IActionResult SendCode(int Code)
        //{
        //    var log = new StudentLog
        //    {
        //        dateTime = DateTime.Now
        //    };
        //    Students student = NstudentRepository.GetStudentByCode(Code);

        //    BackgroundJob.Schedule(() => Reminder(student.Id), TimeSpan.FromMinutes(2));

        //    _mail.GenMail(
        //               student.email, "Your one time pin code to the pingisBox",
        //               "\n Hej " + student.FullName + "\nYour pin code is: " + student.code +
        //               "\nPlease register your card within 24 hours or you will have to request for a new code."
        //               + "Registration Time: " + DateTime.Now.ToString("HH:mm:ss"));

        //    // return RedirectToAction("Index", "Home", new { Ncode = student.code });
        //    Alert("We have sent a onetime pin code to your email address " + student.email, NotificationType.success);
        //    log.Message = "New User with email: " + student.email + " Registered and got the code:" + student.code;
        //    NstudentRepository.AddLog(log);
        //    return RedirectToAction("Index", "Home");

        //}

        public async Task Reminder(int id)
        {
            var log = new StudentLog
            {
                dateTime = DateTime.Now
            };
            Students student = NstudentRepository.GetStudentById(id);

            if (student.RFID == 0)
            {
                _appDbCotext.students.Remove(student);
                await _appDbCotext.SaveChangesAsync();

                log.Message = "The user " + student.email + " did not register his card within 24 hours and has been terminated";
                NstudentRepository.AddLog(log);
            }
        }