/// <summary> /// 邊更打卡時間 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <VerityResult> SubmitClick_In(CheckRecordViewModel model) { VerityResult res = new VerityResult(); try { check_in item = new check_in(); var query = _check_in.FindBy(x => x.ci_sn == model.ci_sn); if (query.Any()) { item = query.FirstOrDefault(); item.ci_ut = model.ci_ut; item.ci_dt = model.ci_dt; var nowDate = item.ci_da.ToString("yyyy-MM-dd"); if (item.ci_ut != TimeSpan.Zero && item.ci_dt != TimeSpan.Zero) { TimeSpan dt1 = item.ci_ut; TimeSpan dt2 = item.ci_dt; TimeSpan ts = dt2.Subtract(dt1); double hours = Math.Round(ts.TotalHours, 1) - 1; if (hours > 0) { item.ci_hr = hours; } } ; item.Remark = "變更打卡時間"; _check_in.Update(item); res.Success = true; res.Message = "變更打卡資料成功"; } } catch { res.Success = false; res.Message = "變更打卡資料失敗"; } return(await Task.Run(() => res)); }
/// <summary> /// 編輯打卡紀錄的時間 /// </summary> /// <param name="model"></param> /// <param name="time"></param> /// <returns></returns> public async Task <JsonResult> SubmitClick_In(CheckRecordViewModel model, UpdateCheckTimeViewModel time) { ResponseViewModel res = new ResponseViewModel(); try { if (time != null) { if (time.ci_ut != "-") { model.ci_ut = TimeSpan.Parse(time.ci_ut); } if (time.ci_dt != "-") { model.ci_dt = TimeSpan.Parse(time.ci_dt); } var result = await _checkRecord.SubmitClick_In(model); SearchTime modelTime = new SearchTime { StartDateTime = DateTime.Parse(model.ci_da.ToString("s")), }; var totalRecord = _totalRecord.CheckTotalRecord(modelTime); res.Success = result.Success; res.Message = result.Message; res.HttpStatusCode = System.Net.HttpStatusCode.OK; } } catch (Exception ex) { res.Exception = ex; res.Success = false; res.Message = "與伺服器連接發生錯誤"; res.HttpStatusCode = System.Net.HttpStatusCode.InternalServerError; } res.ResponseTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); return(Json(res, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 取得打卡時間 /// </summary> /// <param name="ci_sn"></param> /// <returns></returns> public async Task <ResponseViewModel> GetClick_In(int ci_sn) { ResponseViewModel res = new ResponseViewModel(); CheckRecordViewModel click_In_Item = new CheckRecordViewModel(); try { var query = from a in _check_in.FindBy(x => x.ci_sn == ci_sn) join b in _user.GetAll() on a.ur_id equals b.ur_id select new CheckRecordViewModel { ci_sn = a.ci_sn, ur_id = a.ur_id, ci_da = a.ci_da, ci_ut = a.ci_ut, ci_dt = a.ci_dt, ur_ac = b.ur_ac, ci_ct = a.ci_ct, Remark = a.Remark }; if (query.Any()) { click_In_Item = query.FirstOrDefault(); res.Data = click_In_Item; res.Success = true; res.Message = "取得打卡資料成功"; } } catch { res.Success = false; res.Message = "取得打卡資料失敗"; } return(await Task.Run(() => res)); }