public ActionResult ViewBulletin() { ViewBulletinModel ObjViewBulletinModel = new ViewBulletinModel(); try { //initial set of current page, pageSize , Total pages ObjViewBulletinModel.CurrentPage = 1; ObjViewBulletinModel.PageSize = CommonUtils.PageSize; ObjViewBulletinModel.TotalPages = 0; //Get Bulletin List serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Bulletin + "/GetBulletinList", ObjViewBulletinModel); ObjViewBulletinModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewBulletinModel>().Result : null; //ObjViewBulletinModel = objBLBulletin.GetBulletinList(ObjViewBulletinModel); //Set Success Message if comes from save page after click on save button if (!String.IsNullOrEmpty(Convert.ToString(TempData["SucessMessage"]))) { ObjViewBulletinModel.Message = Convert.ToString(TempData["SucessMessage"]); ObjViewBulletinModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower(); TempData["SucessMessage"] = null; } } catch (Exception ex) { ErrorLog(ex, "Bulletin", "View GET"); } return(View("ViewBulletin", ObjViewBulletinModel)); }
/// <summary> /// Delete Bulletin /// </summary> /// <param name="objViewBulletinModel"></param> /// <returns></returns> public ViewBulletinModel DeleteBulletin(ViewBulletinModel objViewBulletinModel) { try { SqlParameter pErrorCode = new SqlParameter("@ErrorCode", objViewBulletinModel.ErrorCode); pErrorCode.Direction = ParameterDirection.Output; SqlParameter pErrorMessage = new SqlParameter("@ErrorMessage", objViewBulletinModel.Message); pErrorMessage.Direction = ParameterDirection.Output; SqlParameter[] parmList = { new SqlParameter("@BulletinID", objViewBulletinModel.DeletedBulletinID) , new SqlParameter("@CreatedBy", objViewBulletinModel.DeletedBy) , pErrorCode , pErrorMessage }; //Call delete stored procedure to delete Bulletin SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_DeleteBulletin, parmList); //set output parameter error code and error message objViewBulletinModel.ErrorCode = Convert.ToInt32(pErrorCode.Value); objViewBulletinModel.Message = Convert.ToString(pErrorMessage.Value); return(objViewBulletinModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get Bulletin List with paging, sorting and searching parameter /// </summary> /// <param name="objViewBulletinModel">object of Model ViewBulletinModel </param> /// <returns></returns> public DataTable GetBulletinList(ViewBulletinModel objViewBulletinModel) { try { SqlParameter[] parmList = { new SqlParameter("BulletinName", objViewBulletinModel.FilterBulletinName) , new SqlParameter("CurrentPage", objViewBulletinModel.CurrentPage) , new SqlParameter("PageSize", objViewBulletinModel.PageSize) , new SqlParameter("SortBy", objViewBulletinModel.SortBy) , new SqlParameter("SortOrder", objViewBulletinModel.SortOrder) }; DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_GetBulletinList, parmList); if (ds != null && ds.Tables.Count > 0) { return(ds.Tables[0]); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get Bulletin List based on paging, searching and sorting parameter /// </summary> /// <param name="objViewBulletinModel">object of Model ViewBulletinModel</param> /// <returns></returns> public ViewBulletinModel GetBulletinList(ViewBulletinModel objViewBulletinModel) { List <BulletinModel> lstBulletinModel = new List <BulletinModel>(); //if FilterBulletinName is NULL than set to empty objViewBulletinModel.FilterBulletinName = objViewBulletinModel.FilterBulletinName ?? String.Empty; //if SortBy is NULL than set to empty objViewBulletinModel.SortBy = objViewBulletinModel.SortBy ?? String.Empty; //call GetBulletinList Method which will retrun datatable of Bulletin DataTable dtBulletin = objDLBulletin.GetBulletinList(objViewBulletinModel); //fetch each row of datable foreach (DataRow dr in dtBulletin.Rows) { //Convert datarow into Model object and set Model object property BulletinModel itemBulletinModel = GetDataRowToEntity <BulletinModel>(dr); //Add Bulletin in List lstBulletinModel.Add(itemBulletinModel); } //set Bulletin List of Model ViewBulletinModel objViewBulletinModel.BulletinList = lstBulletinModel; //if Bulletin List count is not null and greater than 0 Than set Total Pages for Paging. if (objViewBulletinModel != null && objViewBulletinModel.BulletinList != null && objViewBulletinModel.BulletinList.Count > 0) { objViewBulletinModel.CurrentPage = objViewBulletinModel.BulletinList[0].CurrentPage; int totalRecord = objViewBulletinModel.BulletinList[0].TotalCount; if (decimal.Remainder(totalRecord, objViewBulletinModel.PageSize) > 0) { objViewBulletinModel.TotalPages = (totalRecord / objViewBulletinModel.PageSize + 1); } else { objViewBulletinModel.TotalPages = totalRecord / objViewBulletinModel.PageSize; } } else { objViewBulletinModel.TotalPages = 0; objViewBulletinModel.CurrentPage = 1; } return(objViewBulletinModel); }
public ActionResult ViewBulletin(ViewBulletinModel objViewBulletinModel) { try { int ErrorCode = 0; String ErrorMessage = ""; objViewBulletinModel.Message = objViewBulletinModel.MessageType = String.Empty; if (objViewBulletinModel.ActionType == "delete") { //delete serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Bulletin + "/DeleteBulletin", objViewBulletinModel); objViewBulletinModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewBulletinModel>().Result : null; if (Convert.ToInt32(ErrorCode).Equals(0)) { //if error code 0 means delete successfully than set Delete success message. objViewBulletinModel.Message = "Bulletin Deleted Successfully"; objViewBulletinModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower(); } else { //if error code is not 0 means delete error than set Delete error message. objViewBulletinModel.Message = "Error while deleting record"; objViewBulletinModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();; } } //Get Bulletin List based on searching , sorting and paging parameter. serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Bulletin + "/GetBulletinList", objViewBulletinModel); objViewBulletinModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewBulletinModel>().Result : null; } catch (Exception ex) { ErrorLog(ex, "Bulletin", "View POST"); } return(PartialView("_BulletinList", objViewBulletinModel)); }
public ViewBulletinModel GetBulletinList(ViewBulletinModel objViewBulletinModel) { return(objBLBulletin.GetBulletinList(objViewBulletinModel)); }
public ViewBulletinModel DeleteBulletin(ViewBulletinModel objViewBulletinModel) { return(objBLBulletin.DeleteBulletin(objViewBulletinModel)); }