public void FillPackList(string PackIds, int DocumentId) { ViewDocumentModel ObjViewDocumentModel = new ViewDocumentModel(); try { //initial set of current page, pageSize , Total pages ObjViewDocumentModel.CurrentPage = 1; ObjViewDocumentModel.PageSize = int.MaxValue - 1; ObjViewDocumentModel.TotalPages = 0; //Get Document List serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Document + "/GetDocumentList", ObjViewDocumentModel); ObjViewDocumentModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDocumentModel>().Result : null; //ObjViewDocumentModel = objBLDocument.GetDocumentList(ObjViewDocumentModel); if (ObjViewDocumentModel != null && ObjViewDocumentModel.DocumentList != null) { //ViewBag.PackList = ObjViewDocumentModel.DocumentList.Where(x => x.PackIds == string.Empty && x.DocumentID != DocumentId).ToList(); ViewBag.PackList = new MultiSelectList(ObjViewDocumentModel.DocumentList.Where(x => x.PackIds == string.Empty && x.DocumentID != DocumentId).ToList(), "DocumentID", "DocumentTitle", Convert.ToString(string.IsNullOrWhiteSpace(PackIds) ? "" : PackIds).Split(",".ToCharArray())); } } catch (Exception ex) { ErrorLog(ex, "Document", "View GET"); } }
public ActionResult ViewDocument() { ViewDocumentModel ObjViewDocumentModel = new ViewDocumentModel(); try { //initial set of current page, pageSize , Total pages ObjViewDocumentModel.CurrentPage = 1; ObjViewDocumentModel.PageSize = CommonUtils.PageSize; ObjViewDocumentModel.TotalPages = 0; //Get Document List serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Document + "/GetDocumentList", ObjViewDocumentModel); ObjViewDocumentModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDocumentModel>().Result : null; //ObjViewDocumentModel = objBLDocument.GetDocumentList(ObjViewDocumentModel); //Set Success Message if comes from save page after click on save button if (!String.IsNullOrEmpty(Convert.ToString(TempData["SucessMessage"]))) { ObjViewDocumentModel.Message = Convert.ToString(TempData["SucessMessage"]); ObjViewDocumentModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower(); TempData["SucessMessage"] = null; } CaegoryDropDown(ObjViewDocumentModel.FilterCategoryId); SubCatDropDown(ObjViewDocumentModel.FilterSubCatId, ObjViewDocumentModel.FilterCategoryId, null); StepDropDown(0, 0); } catch (Exception ex) { ErrorLog(ex, "Document", "View GET"); } return(View("ViewDocument", ObjViewDocumentModel)); }
/// <summary> /// Delete Sub Category /// </summary> /// <param name="objViewSubCategoryModel"></param> /// <returns></returns> public ViewDocumentModel DeleteDocument(ViewDocumentModel objViewDocumentModel) { try { SqlParameter pErrorCode = new SqlParameter("@ErrorCode", objViewDocumentModel.ErrorCode); pErrorCode.Direction = ParameterDirection.Output; SqlParameter pErrorMessage = new SqlParameter("@ErrorMessage", objViewDocumentModel.Message); pErrorMessage.Direction = ParameterDirection.Output; SqlParameter[] parmList = { new SqlParameter("@DocumentID", objViewDocumentModel.DeletedDocumentID) , new SqlParameter("@CreatedBy", objViewDocumentModel.DeletedBy) , pErrorCode , pErrorMessage }; //Call delete stored procedure to delete category SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_DeleteDocument, parmList); //set output parameter error code and error message objViewDocumentModel.ErrorCode = Convert.ToInt32(pErrorCode.Value); objViewDocumentModel.Message = Convert.ToString(pErrorMessage.Value); return(objViewDocumentModel); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get Document List with paging, sorting and searching parameter /// </summary> /// <param name="objViewDocumentModel">object of Model ViewDocumentModel </param> /// <returns></returns> public DataTable GetDocumentList(ViewDocumentModel objViewDocumentModel) { try { SqlParameter[] parmList = { new SqlParameter("@CategoryID", objViewDocumentModel.FilterCategoryId) , new SqlParameter("@SubCategoryID", objViewDocumentModel.FilterSubCatId) , new SqlParameter("@DocumentTitle", objViewDocumentModel.FilterDocumentTitle) , new SqlParameter("@CurrentPage", objViewDocumentModel.CurrentPage) , new SqlParameter("@PageSize", objViewDocumentModel.PageSize) , new SqlParameter("@SortBy", objViewDocumentModel.SortBy) , new SqlParameter("@SortOrder", objViewDocumentModel.SortOrder) }; DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_GetDocumentList, parmList); if (ds != null && ds.Tables.Count > 0) { return(ds.Tables[0]); } return(null); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get Document List based on paging, searching and sorting parameter /// </summary> /// <param name="objViewDocumentModel">object of Model ViewDocumentModel</param> /// <returns></returns> public ViewDocumentModel GetDocumentList(ViewDocumentModel objViewDocumentModel) { List <DocumentModel> lstDocumentModel = new List <DocumentModel>(); //if FilterDocumentName is NULL than set to empty objViewDocumentModel.FilterSubCatName = objViewDocumentModel.FilterSubCatName ?? String.Empty; //if SortBy is NULL than set to empty objViewDocumentModel.SortBy = objViewDocumentModel.SortBy ?? String.Empty; //call GetDocumentList Method which will retrun datatable of Document DataTable dtDocument = objDLDocument.GetDocumentList(objViewDocumentModel); //fetch each row of datable foreach (DataRow dr in dtDocument.Rows) { //Convert datarow into Model object and set Model object property DocumentModel itemDocumentModel = GetDataRowToEntity <DocumentModel>(dr); //Add Document in List lstDocumentModel.Add(itemDocumentModel); } //set Document List of Model ViewDocumentModel objViewDocumentModel.DocumentList = lstDocumentModel; //if Document List count is not null and greater than 0 Than set Total Pages for Paging. if (objViewDocumentModel != null && objViewDocumentModel.DocumentList != null && objViewDocumentModel.DocumentList.Count > 0) { objViewDocumentModel.CurrentPage = objViewDocumentModel.DocumentList[0].CurrentPage; int totalRecord = objViewDocumentModel.DocumentList[0].TotalCount; if (decimal.Remainder(totalRecord, objViewDocumentModel.PageSize) > 0) { objViewDocumentModel.TotalPages = (totalRecord / objViewDocumentModel.PageSize + 1); } else { objViewDocumentModel.TotalPages = totalRecord / objViewDocumentModel.PageSize; } } else { objViewDocumentModel.TotalPages = 0; objViewDocumentModel.CurrentPage = 1; } return(objViewDocumentModel); }
public ActionResult ViewDocument(ViewDocumentModel objViewDocumentModel) { try { int ErrorCode = 0; String ErrorMessage = ""; objViewDocumentModel.Message = objViewDocumentModel.MessageType = String.Empty; if (objViewDocumentModel.ActionType == "delete") { //delete serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Document + "/DeleteDocument", objViewDocumentModel); objViewDocumentModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDocumentModel>().Result : null; if (Convert.ToInt32(ErrorCode).Equals(0)) { //if error code 0 means delete successfully than set Delete success message. objViewDocumentModel.Message = "Document Deleted Successfully"; objViewDocumentModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower(); } else { //if error code is not 0 means delete error than set Delete error message. objViewDocumentModel.Message = "Error while deleting record"; objViewDocumentModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();; } } //Get Document List based on searching , sorting and paging parameter. serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.Document + "/GetDocumentList", objViewDocumentModel); objViewDocumentModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewDocumentModel>().Result : null; CaegoryDropDown(objViewDocumentModel.FilterCategoryId); SubCatDropDown(objViewDocumentModel.FilterSubCatId, objViewDocumentModel.FilterCategoryId, null); } catch (Exception ex) { ErrorLog(ex, "Document", "View POST"); } return(PartialView("_DocumentList", objViewDocumentModel)); }
public ViewDocumentModel DeleteDocument(ViewDocumentModel objViewDocumentModel) { return(objDLDocument.DeleteDocument(objViewDocumentModel)); }
public ViewDocumentModel GetDocumentList(ViewDocumentModel objViewDocumentModel) { return(objBLDocument.GetDocumentList(objViewDocumentModel)); }