public async Task <ActionResult> CheckIn([Bind(Include = "ID,PhoneNumberID,Checkin,Checkout,Purpose,Device,Purpose2, Comment, DepartmentID")] CheckinCheckout checkinCheckout, string Purpose2, string Device2) { var otherText = "ອື່ນໆ..."; if (checkinCheckout.Purpose == otherText) { checkinCheckout.Purpose = Purpose2; } if (checkinCheckout.Device == otherText) { checkinCheckout.Device = Device2; } if (checkinCheckout.Device == "") { checkinCheckout.Device = null; } checkinCheckout.ID = Guid.NewGuid(); checkinCheckout.Checkin = DateTimeOffset.Now; db.CheckinCheckouts.Add(checkinCheckout); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task<ActionResult> Create([Bind(Include = "PhoneNumberID,FullName,Source,EmployeeID,IsActive")] Person person) { if (ModelState.IsValid) { db.People.Add(person); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(person); }
public async Task <ActionResult> Create([Bind(Include = "ID,PhoneNumberID,Checkin,Checkout,Purpose,Device,Comment,DepartmentID")] CheckinCheckout checkinCheckout) { if (ModelState.IsValid) { checkinCheckout.ID = Guid.NewGuid(); db.CheckinCheckouts.Add(checkinCheckout); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.PhoneNumberID = new SelectList(db.People, "PhoneNumberID", "FullName", checkinCheckout.PhoneNumberID); ViewBag.DepartmentID = new SelectList(db.Departments, "ID", "Department1", checkinCheckout.DepartmentID); return(View(checkinCheckout)); }
private async Task SendDailyAbsentSms() { if (!(this.SendAbsentSms_LastRunTime.Date < DateTime.Now.Date && DateTime.Now.TimeOfDay > this.AttendanceConfig.shift1_absent_notification_cutoff_time && !IsBusy)) { return; } if (this.AttendanceConfig.is_enable_sms_service) { logger.Info($"Send Absent Sms - Start".ToUpper()); this.SendAbsentSms_LastRunTime = DateTime.Now; this.IsBusy = true; DateTime processDate = DateTime.Now.Date; try { using (AttendanceDbContext dbContext = new AttendanceDbContext()) { var studentAttendences = dbContext.StudentAttendences.Include(x => x.StudentSession) .Include("StudentSession.Student") .Where(x => x.date == processDate && x.attendence_type_id == StudentAbsentTypeId) .ToList(); foreach (var attendance in studentAttendences) { if (attendance.remark != "SMS sent.") { if (this.SendSms(SmsType.Absent, attendance.StudentSession.Student, processDate)) { attendance.remark = "SMS sent."; } else { attendance.remark = "SMS fail to send!"; } } } await dbContext.SaveChangesAsync(); } } catch (Exception ex) { logger.Error(ex.Message, ex); } finally { this.IsBusy = false; logger.Info($"Send Absent Sms - End".ToUpper()); } } }
public async Task SaveChangesAsync() { await db.SaveChangesAsync(); }