public IEnumerable <sp_emp_temporary_search_v2_Result> search_Temporary(empCheckInModel value) { try { JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(value); StandardCanEntities context = new StandardCanEntities(); if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } context.interface_log.Add(new interface_log { ID = 1, data_log = json, module = "search_Temporary", update_date = DateTime.Now }); context.SaveChanges(); IEnumerable <sp_emp_temporary_search_v2_Result> result = context.sp_emp_temporary_search_v2(userId, value.start_date, value.stop_date, value.emp_code_from, value.emp_code_to, value.depart_from, value.depart_to, value.fname, value.lname).AsEnumerable(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public messageModel delete_temporary(empCheckInModel value) { messageModel result = new messageModel(); try { using (var context = new StandardCanEntities()) { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } int ret = context.sp_emp_temporary_delete(value.id, userId); } result.status = "S"; result.message = ""; } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }
public timeAttRealtimeMasterModel master(empCheckInModel value) { timeAttRealtimeMasterModel result = new timeAttRealtimeMasterModel(); try { using (var context = new StandardCanEntities()) { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } string sql = "select convert(nvarchar(5), MD_ID) code "; sql += " , md_name [text] "; sql += " from MAS_DEPARTMENT "; sql += " where md_status = 1 "; sql += " order by md_name "; result.department = context.Database.SqlQuery <dropdown>(sql).ToList(); } } catch (Exception ex) { throw new Exception(ex.Message); } return(result); }
public messageModel save_Regular(empCheckInModel value) { messageModel result = new messageModel(); try { JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(value); using (var context = new StandardCanEntities()) { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } context.interface_log.Add(new interface_log { ID = 1, data_log = json, module = "save_Regular", update_date = DateTime.Now }); context.SaveChanges(); int ret = context.sp_emp_regular_delete(userId); if (value.data != null) { foreach (var item in value.data) { context.sp_emp_regular_insert(userId, item.emp_code); } } } result.status = "S"; result.message = ""; } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }
// POST: api/empCheckInTemporary public HttpResponseMessage Post([FromBody] empCheckInModel value) { if (value == null) { return(null); } JavaScriptSerializer js = new JavaScriptSerializer(); empCheckInService service = new empCheckInService(); HttpResponseMessage response = null; Object result = null; switch (value.method) { case "master": result = service.master(value); break; case "search": result = service.search_Temporary(value); break; case "save": result = service.save_Temporary(value); break; case "delete": result = service.delete_temporary(value); break; default: break; } string json = js.Serialize(result); response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); return(response); }
public messageModel save_Temporary(empCheckInModel value) { messageModel result = new messageModel(); try { using (var context = new StandardCanEntities()) { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } if (value.data != null) { foreach (var item in value.data) { context.sp_emp_temporary_save(userId, item.id, item.emp_code, item.start_date, item.stop_date); } } } result.status = "S"; result.message = ""; } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }
public IEnumerable <sp_emp_regular_search_v2_Result> search_Regular(empCheckInModel value) { try { if (String.IsNullOrEmpty(value.user_id)) { throw new Exception("Unauthorized Access"); } var userId = JwtHelper.GetUserIdFromToken(value.user_id); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } StandardCanEntities context = new StandardCanEntities(); IEnumerable <sp_emp_regular_search_v2_Result> result = context.sp_emp_regular_search_v2(value.user_id).AsEnumerable(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }