public ActionResult ViewMaster()
        {
            ViewMasterModel ObjViewMasterModel = new ViewMasterModel();

            try
            {
                //initial set of current page, pageSize , Total pages
                ObjViewMasterModel.CurrentPage = 1;
                ObjViewMasterModel.PageSize    = CommonUtils.PageSize;
                ObjViewMasterModel.TotalPages  = 0;
                //Get  Master List
                serviceResponse    = objUtilityWeb.PostAsJsonAsync(WebApiURL.Master + "/GetMasterList", ObjViewMasterModel);
                ObjViewMasterModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewMasterModel>().Result : null;
                //ObjViewMasterModel = objBLMaster.GetMasterList(ObjViewMasterModel);

                //Set Success Message if comes from save  page after click on save button
                if (!String.IsNullOrEmpty(Convert.ToString(TempData["SucessMessage"])))
                {
                    ObjViewMasterModel.Message     = Convert.ToString(TempData["SucessMessage"]);
                    ObjViewMasterModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower();
                    TempData["SucessMessage"]      = null;
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "Master", "View GET");
            }
            return(View("ViewMaster", ObjViewMasterModel));
        }
Beispiel #2
0
        /// <summary>
        /// Delete Sub Category
        /// </summary>
        /// <param name="objViewSubCategoryModel"></param>
        /// <returns></returns>
        public ViewMasterModel DeleteMaster(ViewMasterModel objViewMasterModel)
        {
            try
            {
                SqlParameter pErrorCode = new SqlParameter("@ErrorCode", objViewMasterModel.ErrorCode);
                pErrorCode.Direction = ParameterDirection.Output;
                SqlParameter pErrorMessage = new SqlParameter("@ErrorMessage", objViewMasterModel.Message);
                pErrorMessage.Direction = ParameterDirection.Output;

                SqlParameter[] parmList =
                {
                    new SqlParameter("@MasterID", objViewMasterModel.DeletedMasterID)
                    ,                             new SqlParameter("@CreatedBy", objViewMasterModel.DeletedBy)
                    ,                             pErrorCode
                    ,                             pErrorMessage
                };
                //Call delete stored procedure to delete  category
                SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_DeleteMaster, parmList);
                //set output parameter error code and error message
                objViewMasterModel.ErrorCode = Convert.ToInt32(pErrorCode.Value);
                objViewMasterModel.Message   = Convert.ToString(pErrorMessage.Value);
                return(objViewMasterModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get  Master List  with paging, sorting and searching parameter
        /// </summary>
        /// <param name="objViewMasterModel">object of Model ViewMasterModel </param>
        /// <returns></returns>
        public DataTable GetMasterList(ViewMasterModel objViewMasterModel)
        {
            try
            {
                SqlParameter[] parmList =
                {
                    new SqlParameter("@MasterValue", objViewMasterModel.FilterMasterText)
                    ,                                new SqlParameter("@CurrentPage", objViewMasterModel.CurrentPage)
                    ,                                new SqlParameter("@PageSize", objViewMasterModel.PageSize)
                    ,                                new SqlParameter("@SortBy", objViewMasterModel.SortBy)
                    ,                                new SqlParameter("@SortOrder", objViewMasterModel.SortOrder)
                };

                DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Admin_GetMasterList, parmList);

                if (ds != null && ds.Tables.Count > 0)
                {
                    return(ds.Tables[0]);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Get  Master List based on paging, searching and sorting parameter
        /// </summary>
        /// <param name="objViewMasterModel">object of Model ViewMasterModel</param>
        /// <returns></returns>
        public ViewMasterModel GetMasterList(ViewMasterModel objViewMasterModel)
        {
            List <MasterModel> lstMasterModel = new List <MasterModel>();

            //if FilterMasterName is NULL than set to empty
            objViewMasterModel.FilterSubCatName = objViewMasterModel.FilterSubCatName ?? String.Empty;

            //if SortBy is NULL than set to empty
            objViewMasterModel.SortBy = objViewMasterModel.SortBy ?? String.Empty;

            //call GetMasterList Method which will retrun datatable of  Master
            DataTable dtMaster = objDLMaster.GetMasterList(objViewMasterModel);

            //fetch each row of datable
            foreach (DataRow dr in dtMaster.Rows)
            {
                //Convert datarow into Model object and set Model object property
                MasterModel itemMasterModel = GetDataRowToEntity <MasterModel>(dr);
                //Add  Master in List
                lstMasterModel.Add(itemMasterModel);
            }

            //set Master List of Model ViewMasterModel
            objViewMasterModel.MasterList = lstMasterModel;
            //if  Master List count is not null and greater than 0 Than set Total Pages for Paging.
            if (objViewMasterModel != null && objViewMasterModel.MasterList != null && objViewMasterModel.MasterList.Count > 0)
            {
                objViewMasterModel.CurrentPage = objViewMasterModel.MasterList[0].CurrentPage;
                int totalRecord = objViewMasterModel.MasterList[0].TotalCount;

                if (decimal.Remainder(totalRecord, objViewMasterModel.PageSize) > 0)
                {
                    objViewMasterModel.TotalPages = (totalRecord / objViewMasterModel.PageSize + 1);
                }
                else
                {
                    objViewMasterModel.TotalPages = totalRecord / objViewMasterModel.PageSize;
                }
            }
            else
            {
                objViewMasterModel.TotalPages  = 0;
                objViewMasterModel.CurrentPage = 1;
            }
            return(objViewMasterModel);
        }
        public ActionResult ViewMaster(ViewMasterModel objViewMasterModel)
        {
            try
            {
                int    ErrorCode    = 0;
                String ErrorMessage = "";
                objViewMasterModel.Message = objViewMasterModel.MessageType = String.Empty;

                if (objViewMasterModel.ActionType == "delete")
                {
                    //delete
                    serviceResponse    = objUtilityWeb.PostAsJsonAsync(WebApiURL.Master + "/DeleteMaster", objViewMasterModel);
                    objViewMasterModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewMasterModel>().Result : null;

                    if (Convert.ToInt32(ErrorCode).Equals(0))
                    {
                        //if error code 0 means delete successfully than set Delete success message.
                        objViewMasterModel.Message     = "Master Deleted Successfully";
                        objViewMasterModel.MessageType = CommonUtils.MessageType.Success.ToString().ToLower();
                    }
                    else
                    {
                        //if error code is not 0 means delete error  than set Delete error message.
                        objViewMasterModel.Message     = "Error while deleting record";
                        objViewMasterModel.MessageType = CommonUtils.MessageType.Error.ToString().ToLower();;
                    }
                }
                //Get  Master List based on searching , sorting and paging parameter.

                serviceResponse    = objUtilityWeb.PostAsJsonAsync(WebApiURL.Master + "/GetMasterList", objViewMasterModel);
                objViewMasterModel = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <ViewMasterModel>().Result : null;
            }
            catch (Exception ex)
            {
                ErrorLog(ex, "Master", "View POST");
            }
            return(PartialView("_MasterList", objViewMasterModel));
        }
Beispiel #6
0
 public ViewMasterModel GetMasterList(ViewMasterModel objViewMasterModel)
 {
     return(objBLMaster.GetMasterList(objViewMasterModel));
 }
Beispiel #7
0
 public ViewMasterModel DeleteMaster(ViewMasterModel objViewMasterModel)
 {
     return(objBLMaster.DeleteMaster(objViewMasterModel));
 }