public JsonResult InsertAttendanceType(AttendanceType type)
        {
            try
            {
                db.AttendanceTypes.Add(type);
                type.CreateBy   = AppUtils.GetLoginUserID();
                type.CreateDate = AppUtils.GetDateTimeNow();
                type.Status     = AppUtils.TableStatusIsActive;
                db.AttendanceTypes.Add(type);
                db.SaveChanges();
                AttendanceTypeViewModel AttendanceTypeInfo = new AttendanceTypeViewModel
                {
                    AttendanceTypeID     = type.AttendanceTypeID,
                    AttendanceName       = type.AttendanceName,
                    UpdateAttendanceType = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Attendance_Type) ? true : false,
                };


                return(Json(new { SuccessInsert = true, AttendanceTypeInfo = AttendanceTypeInfo }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { SuccessInsert = false }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult UpdateAttendanceType(AttendanceType type)
        {
            try
            {
                AttendanceType dbAttendanceType = new AttendanceType();
                dbAttendanceType = db.AttendanceTypes.Find(type.AttendanceTypeID);
                dbAttendanceType.AttendanceName  = type.AttendanceName;
                dbAttendanceType.UpdateBy        = AppUtils.GetLoginUserID();
                dbAttendanceType.UpdateDate      = AppUtils.GetDateTimeNow();
                db.Entry(dbAttendanceType).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                var AttendacnceType =
                    new AttendanceTypeViewModel()
                {
                    AttendanceTypeID     = type.AttendanceTypeID,
                    AttendanceName       = type.AttendanceName,
                    UpdateAttendanceType = ISP_ManagementSystemModel.AppUtils.HasAccessInTheList(ISP_ManagementSystemModel.AppUtils.Update_Attendance_Type) ? true : false,
                };
                var JSON = Json(new { UpdateSuccess = true, AttenDanceTypeInformation = AttendacnceType }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch
            {
                return(Json(new { UpdateSuccess = false, EMPLH = "" }, JsonRequestBehavior.AllowGet));
            }
        }
        public IHttpActionResult GetAttendanceType([FromUri] int id)
        {
            Exception ex = null;
            AttendanceTypeViewModel result = null;

            try {
                var attendanceType = _dataProvider.GetEntity <AttendanceType>(id);
                result = new AttendanceTypeViewModel(attendanceType);

                result.AddLink(new Link(Request.RequestUri, HttpMethod.Get, RelValues.Self, ActionValues.Refresh, "AttendanceTypes/" + id));
                result.AddLink(new Link(Request.RequestUri, HttpMethod.Put, RelValues.Self, ActionValues.Save, "AttendanceTypes/" + id));
                result.AddLink(new Link(Request.RequestUri, HttpMethod.Delete, RelValues.Self, ActionValues.Delete, "AttendanceTypes/" + id));
            } catch (Exception e) {
                ex = e;
            }

            return(GetHttpActionResult(ex));
        }