public messageModel update(configmeetingModel 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_configmeeting_update(value.id, value.timelimit, value.desc, value.score, userId); } result.status = "S"; result.message = ""; } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }
public messageModel insert(configmeetingModel value) { messageModel result = new messageModel(); try { System.Data.Entity.Core.Objects.ObjectParameter myOutputParamInt = new System.Data.Entity.Core.Objects.ObjectParameter("r_id", typeof(Int32)); 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_configmeeting_insert(value.timelimit, value.desc, value.score, userId, myOutputParamInt); } if (myOutputParamInt.Value != null) { int r_id = Convert.ToInt32(myOutputParamInt.Value); result.status = "S"; result.message = ""; result.value = r_id.ToString(); } else { result.status = "E"; result.message = ""; } } catch (Exception ex) { result.status = "E"; result.message = ex.Message.ToString(); } return(result); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] configmeetingModel value) { if (value == null) { return(null); } JavaScriptSerializer js = new JavaScriptSerializer(); configmeetingService service = new configmeetingService(); HttpResponseMessage response = null; Object result = null; switch (value.method) { case "search": result = service.search(value); break; case "insert": result = service.insert(value); break; case "update": result = service.update(value); break; case "delete": result = service.delete(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 IEnumerable <sp_configmeeting_search_Result> search(configmeetingModel value) { try { 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"); } IEnumerable <sp_configmeeting_search_Result> result = context.sp_configmeeting_search(value.desc).AsEnumerable(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }