public async Task <ActionResult> DeleteConfirmed(int id)
        {
            T_EmployeeAttendance t_EmployeeAttendance = await db.T_EmployeeAttendance.FindAsync(id);

            db.T_EmployeeAttendance.Remove(t_EmployeeAttendance);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        // GET: EmployeeAttendance/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_EmployeeAttendance t_EmployeeAttendance = await db.T_EmployeeAttendance.FindAsync(id);

            if (t_EmployeeAttendance == null)
            {
                return(HttpNotFound());
            }
            return(View(t_EmployeeAttendance));
        }
        public async Task <ActionResult> Edit([Bind(Include = "AttendanceID,EmployeeID,InTime,OutTime,Reason,CreatedBy,CreatedDate,Active")] T_EmployeeAttendance t_EmployeeAttendance)
        {
            if (ModelState.IsValid)
            {
                t_EmployeeAttendance.ModifiedBy      = Session["LoginUserID"].ToString();
                t_EmployeeAttendance.ModifiedDate    = DateTime.Now;
                db.Entry(t_EmployeeAttendance).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.EmployeeID = new SelectList(db.M_EmployeeMasters, "EmployeeID", "EmployeeName", t_EmployeeAttendance.EmployeeID);
            return(View(t_EmployeeAttendance));
        }
        // GET: EmployeeAttendance/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_EmployeeAttendance t_EmployeeAttendance = await db.T_EmployeeAttendance.FindAsync(id);

            if (t_EmployeeAttendance == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeID = new SelectList(db.M_EmployeeMasters, "EmployeeID", "EmployeeName", t_EmployeeAttendance.EmployeeID);
            return(View(t_EmployeeAttendance));
        }
        public ActionResult MarkAttendance()
        {
            T_EmployeeAttendance t_EmployeeAttendance = new T_EmployeeAttendance();

            t_EmployeeAttendance.EmployeeID   = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.InTime       = DateTime.Now;
            t_EmployeeAttendance.CreatedBy    = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.CreatedDate  = DateTime.Now;
            t_EmployeeAttendance.ModifiedBy   = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.ModifiedDate = DateTime.Now;
            t_EmployeeAttendance.Active       = true;
            db.T_EmployeeAttendance.Add(t_EmployeeAttendance);
            db.SaveChanges();
            ViewBag.AttendanceMark = "Attendance Mark Successfully on : " + t_EmployeeAttendance.InTime;
            return(RedirectToAction("Index"));
        }
        public ActionResult AttendanceLogout(int AttendanceID)
        {
            if (AttendanceID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_EmployeeAttendance t_EmployeeAttendance = db.T_EmployeeAttendance.Where(x => x.AttendanceID == AttendanceID).OrderByDescending(x => x.AttendanceID).FirstOrDefault();

            if (t_EmployeeAttendance == null)
            {
                return(HttpNotFound());
            }
            t_EmployeeAttendance.OutTime         = DateTime.Now;
            t_EmployeeAttendance.ModifiedBy      = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.ModifiedDate    = DateTime.Now;
            db.Entry(t_EmployeeAttendance).State = EntityState.Modified;
            db.SaveChanges();
            ViewBag.AttendanceMark = "Attendance Logout Successfully on : " + t_EmployeeAttendance.InTime;
            return(RedirectToAction("Index"));
        }
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Create([Bind(Include = "EmployeeID,InTime,Reason")] T_EmployeeAttendance t_EmployeeAttendance)
        {
            //if (ModelState.IsValid)
            //{
            t_EmployeeAttendance.EmployeeID   = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.InTime       = DateTime.Now;
            t_EmployeeAttendance.CreatedBy    = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.CreatedDate  = DateTime.Now;
            t_EmployeeAttendance.ModifiedBy   = Session["LoginUserID"].ToString();
            t_EmployeeAttendance.ModifiedDate = DateTime.Now;
            t_EmployeeAttendance.Active       = true;
            db.T_EmployeeAttendance.Add(t_EmployeeAttendance);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));

            //}

            ViewBag.EmployeeID = new SelectList(db.M_EmployeeMasters, "EmployeeID", "EmployeeName", t_EmployeeAttendance.EmployeeID);
            return(View(t_EmployeeAttendance));
        }