public ActionResult Edit(BookModel model) { JsonResult retData = new JsonResult(); try { RESTResult Result = (new REST(Global.WebAPIBaseURL, "/api/Training/BookDB/V1/App/Book/GetOneBook?BookID=" + model.BookID, REST.Method.GET)).Result; if (Result.Success) { retData = Json(new { Status = "Success", Data = Result.Deserialize <BookModel>() }); } else { retData = Json(new { Status = "Failed", Message = "Failed when getting data.." }); } } catch (Exception ex) { retData = Json(new { Status = "Failed", Message = ex.Message }); } return(retData); }
public ActionResult BorrowIndex() { try { RESTResult Result = (new REST(Global.WebAPIBaseURL, "/api/Training/BookDB/V1/App/Book/BorrowIndex", REST.Method.GET)).Result; HomeViewModel hvm = new HomeViewModel(); hvm.borrow = Result.Deserialize <List <BorrowModel> >(); return(View("borrow", hvm)); } catch (Exception ex) { throw ex; } }
public ActionResult GetAssignment(int AssignmentID) { JsonResult retData = new JsonResult(); try { RESTResult Result = (new REST(Global.WebAPIBaseURL, "/api/Training/RecDB/V1/App/Assignment/GetAssignment?AssignmentID=" + AssignmentID, REST.Method.GET)).Result; if (Result.Success) { AssignmentModel model = Result.Deserialize <AssignmentModel>(); var temp = new { AssignmentID = model.AssignmentID, Title = model.Title, Description = model.Description, AssignmentFilepath = model.AssignmentFilepath, DateDue = model.DateDue.ToString("s"), DateUploaded = model.DateUploaded.ToString("s") }; retData = Json(new { Status = "Success", Message = "Get Assignment Success!", Data = temp }); } else { retData = Json(new { Status = "Failed", Message = "Failed When Getting Data.." }); } } catch (Exception ex) { retData = Json(new { Status = "Failed", Message = ex.Message }); } return(retData); }
public ActionResult GetScheduleByID(string ScheduleID) { JsonResult retData = new JsonResult(); try { RESTResult Result = (new REST(Global.WebAPIBaseURL, "/api/Training/RecDB/V1/App/Schedule/GetScheduleByID?ScheduleID=" + ScheduleID, REST.Method.GET)).Result; ScheduleModel Schedule = Result.Deserialize <ScheduleModel>(); if (Result.Success) { retData = Json(new { Status = "Success", Message = "Get Schedule Success!", Data = new { ScheduleID = Schedule.ScheduleID, Place = Schedule.Place, StartTime = Schedule.StartTime.ToString("s"), EndTime = Schedule.EndTime.ToString("s"), Topic = Schedule.Topic, Description = Schedule.Description } }); } else { retData = Json(new { Status = "Failed", Message = "Failed When Getting Data.." }); } } catch (Exception ex) { retData = Json(new { Status = "Failed", Message = ex.Message }); } return(retData); }
public ActionResult GetPostByID(int PostID) { JsonResult retData = new JsonResult(); try { RESTResult Result = (new REST(Global.WebAPIBaseURL, "/api/Training/RecDB/V1/App/Post/GetPostByID?PostID=" + PostID, REST.Method.GET)).Result; PostModel Post = Result.Deserialize <PostModel>(); if (Result.Success) { retData = Json(new { Status = "Success", Message = "Get Post Success!", Data = new { PostID = Post.PostID, ThreadID = Post.ThreadID, UserID = Post.UserID, Content = Post.Content } }); } else { retData = Json(new { Status = "Failed", Message = "Failed When Getting Data.." }); } } catch (Exception ex) { retData = Json(new { Status = "Failed", Message = ex.Message }); } return(retData); }
public ActionResult GetOneThread(int ThreadID) { JsonResult retData = new JsonResult(); try { RESTResult Result = (new REST(Global.WebAPIBaseURL, "api/Training/RecDB/V1/App/Thread/GetOneThread?ThreadID=" + ThreadID, REST.Method.GET)).Result; if (Result.Success) { retData = Json(new { Status = "Success", Message = "Get Thread Success!", Data = Result.Deserialize <ThreadModel>() }); } else { retData = Json(new { Status = "Failed", Message = "Failed When Getting Data.." }); } } catch (Exception ex) { retData = Json(new { Status = "Failed", Message = ex.Message }); } return(retData); }
public ActionResult Index() { JsonResult RetData = new JsonResult(); try { HomeViewModel hvm = new HomeViewModel(); RESTResult Result = (new REST(Global.WebAPIBaseURL, "/api/Training/BookDB/V1/App/Book/GetAllBooks", REST.Method.GET, REST.NeedOAuth.False)).Result; if (Result.Success) { hvm.Books = Result.Deserialize <List <BookModel> >(); } else { hvm.Books = new List <BookModel>(); } return(View("index", hvm)); } catch (Exception ex) { throw ex; } }