public IHttpActionResult RetrieveData(int id) { ApiResData res = new ApiResData(); try { TOURIS_TM_SLIDESHOW slideshow = repo.Retrieve(id); TOURIS_TV_SLIDESHOW slideshowView = new TOURIS_TV_SLIDESHOW(); if (slideshow != null) { slideshowView.ID = slideshow.ID; slideshowView.TITTLE = slideshow.TITTLE; slideshowView.CONTENT_DESCRIPTION = slideshow.CONTENT_DESCRIPTION; slideshowView.CLASS = slideshow.CLASS; slideshowView.PHOTO_PATH = slideshow.PHOTO_PATH; slideshowView.URL = slideshow.URL; slideshowView.CREATED_BY = slideshow.CREATED_BY; slideshowView.CREATED_TIME = slideshow.CREATED_TIME; slideshowView.LAST_MODIFIED_BY = slideshow.LAST_MODIFIED_BY; slideshowView.LAST_MODIFIED_TIME = slideshow.LAST_MODIFIED_TIME; rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { slideshowView }, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public ActionResult Delete(int id) { TOURIS_TV_SLIDESHOW slideshowView = new TOURIS_TV_SLIDESHOW(); TOURIS_TV_SLIDESHOW slideshowRes = new TOURIS_TV_SLIDESHOW(); slideshowView.ID = id; slideshowRes = JsonConvert.DeserializeObject <TOURIS_TV_SLIDESHOW>(ParsingObject.RequestData(id, "Slideshow", "RetrieveData", EnumList.IHttpMethod.Put.ToString())); return(View(slideshowRes)); }
public IHttpActionResult Add(TOURIS_TV_SLIDESHOW slideshowView) { ApiResData res = new ApiResData(); try { if (!ModelState.IsValid) { rs.SetErrorStatus(eFunc.fg.SFailed); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid))); return(Content(HttpStatusCode.NotFound, resObj)); } TOURIS_TM_SLIDESHOW slideshow = new TOURIS_TM_SLIDESHOW(); slideshow.TITTLE = slideshowView.TITTLE; slideshow.CONTENT_DESCRIPTION = slideshowView.CONTENT_DESCRIPTION; slideshow.CLASS = slideshowView.CLASS; slideshow.PHOTO_PATH = slideshowView.PHOTO_PATH; slideshow.URL = slideshowView.URL; slideshow.CREATED_BY = slideshowView.CREATED_BY; slideshow.CREATED_TIME = slideshowView.CREATED_TIME; slideshow.ROW_STATUS = eStat.fg.IsActive; rs = repo.Add(slideshow); if (rs.IsSuccess) { rs.SetSuccessStatus(); } else { rs.SetErrorStatus(eFunc.fg.SFailed); } resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public ActionResult ActionEdit(TOURIS_TV_SLIDESHOW slideshowView, HttpPostedFileBase postedFile) { try { string physicalPath = ""; if (postedFile != null) { string ImageName = System.IO.Path.GetFileName(postedFile.FileName); //file2 to store path and url physicalPath = Server.MapPath("~" + Common.GetPathFolderImg() + ImageName); slideshowView.PHOTO_PATH = Common.GetPathFolderImg() + ImageName; } slideshowView.LAST_MODIFIED_BY = CurrentUser.GetCurrentUserId(); slideshowView.LAST_MODIFIED_TIME = CurrentUser.GetCurrentDateTime(); rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.RequestData(slideshowView, "Slideshow", "Edit", EnumList.IHttpMethod.Post.ToString())); if (rs.IsSuccess) { if (physicalPath != "") { postedFile.SaveAs(physicalPath); } rs.SetSuccessStatus("Data has been edited successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to edited"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to edited"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }
public IHttpActionResult GridBind() { ApiResData res = new ApiResData(); try { List <TOURIS_TM_SLIDESHOW> countries = repo.GridBind(); List <TOURIS_TV_SLIDESHOW> slideshowViews = new List <TOURIS_TV_SLIDESHOW>(); if (countries.Count > 0) { foreach (var item in countries) { TOURIS_TV_SLIDESHOW slideshowView = new TOURIS_TV_SLIDESHOW(); slideshowView.ID = item.ID; slideshowView.TITTLE = item.TITTLE; slideshowView.CONTENT_DESCRIPTION = item.CONTENT_DESCRIPTION; slideshowView.CLASS = item.CLASS; slideshowView.PHOTO_PATH = item.PHOTO_PATH; slideshowView.URL = item.URL; slideshowView.CREATED_BY = item.CREATED_BY; slideshowView.CREATED_TIME = item.CREATED_TIME; slideshowView.LAST_MODIFIED_BY = item.LAST_MODIFIED_BY; slideshowView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME; slideshowViews.Add(slideshowView); } rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { slideshowViews }, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf))); return(Content(HttpStatusCode.BadRequest, resObj)); } }