public IEnumerable <MasterDirectionIndex> GetMasterDirectionIndex(MasterDirectionIndex masterDirectionIndex) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int)); ObjectParameter totalRecord = new ObjectParameter("TotalRecord", typeof(int)); var masterDirectionIndexes = dataContext.MasterDirectionIndexGet(masterDirectionIndex.MasterDirectionIndexId, masterDirectionIndex.MasterDirectionId, masterDirectionIndex.MasterDirectionChapterId, Utility.TrimString(masterDirectionIndex.SearchText), masterDirectionIndex.IsActive, masterDirectionIndex.PageNumber, masterDirectionIndex.PageSize, masterDirectionIndex.IsPagingRequired, Utility.TrimString(masterDirectionIndex.OrderBy), Utility.TrimString(masterDirectionIndex.OrderByDirection), totalPageCount, totalRecord).ToList(); var masterDirectionIndexList = new List <MasterDirectionIndex>(); foreach (var masterDirectionIndexDetail in masterDirectionIndexes) { masterDirectionIndexList.Add(new MasterDirectionIndex() { MasterDirectionIndexId = masterDirectionIndexDetail.MDPartIndexID, MasterDirectionChapterId = masterDirectionIndexDetail.MDPID, IndexNo = masterDirectionIndexDetail.ParaIndexNo, IndexName = masterDirectionIndexDetail.IndexName, IndexContent = masterDirectionIndexDetail.IndexContent, SortId = masterDirectionIndexDetail.SortId, IsActive = masterDirectionIndexDetail.IsActive, TotalPageCount = Convert.ToInt32(totalPageCount.Value), TotalRecord = Convert.ToInt32(totalRecord.Value) }); } return(masterDirectionIndexList); } }
public IHttpActionResult UpdateMasterDirectionIndex(UpdateMasterDirectionIndexRequest updateMasterDirectionIndexRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } var masterDirectionIndex = new MasterDirectionIndex() { MasterDirectionIndexId = updateMasterDirectionIndexRequest.MasterDirectionIndexId, MasterDirectionChapterId = updateMasterDirectionIndexRequest.MasterDirectionChapterId, IndexNo = updateMasterDirectionIndexRequest.IndexNo, IndexName = updateMasterDirectionIndexRequest.IndexName, IndexContent = updateMasterDirectionIndexRequest.IndexContent, SaveAfterIndexId = updateMasterDirectionIndexRequest.SaveAfterIndexId, ModifiedBy = Utility.UserId }; int result = iMasterDirectionIndex.UpdateMasterDirectionIndex(masterDirectionIndex); switch (result) { case 1: responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "MasterDirectionIndex updated successfully."; break; case -2: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "MasterDirectionIndex already exists."; break; case -3: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "MasterDirectionIndex doesn't exist."; break; default: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while updating MasterDirectionIndex."; break; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while updating MasterDirectionIndex."; Utility.WriteLog("UpdateMasterDirectionIndex", updateMasterDirectionIndexRequest, "Error while updating MasterDirectionIndex. (MasterDirectionIndexAdminController)", ex.ToString()); } return(Ok(responses)); }
public int DeleteMasterDirectionIndex(MasterDirectionIndex masterDirectionIndex) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); dataContext.MasterDirectionIndexDelete(masterDirectionIndex.MasterDirectionIndexId, masterDirectionIndex.MasterDirectionChapterId, masterDirectionIndex.ModifiedBy, result); return(Convert.ToInt32(result.Value)); } }
public int UpdateMasterDirectionIndex(MasterDirectionIndex masterDirectionIndex) { using (DemsifyEntities dataContext = new DemsifyEntities()) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); dataContext.MasterDirectionIndexUpdate(masterDirectionIndex.MasterDirectionIndexId, masterDirectionIndex.MasterDirectionChapterId, Utility.TrimString(masterDirectionIndex.IndexNo), Utility.TrimString(masterDirectionIndex.IndexName), Utility.TrimString(masterDirectionIndex.IndexContent), masterDirectionIndex.SaveAfterIndexId, masterDirectionIndex.ModifiedBy, result); return(Convert.ToInt32(result.Value)); } }
public IHttpActionResult AddMasterDirectionIndex(AddMasterDirectionIndexRequest addMasterDirectionIndexRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var masterDirectionIndex = new MasterDirectionIndex() { MasterDirectionChapterId = addMasterDirectionIndexRequest.MasterDirectionChapterId, IndexNo = addMasterDirectionIndexRequest.IndexNo, IndexName = addMasterDirectionIndexRequest.IndexName, IndexContent = addMasterDirectionIndexRequest.IndexContent, SaveAfterIndexId = addMasterDirectionIndexRequest.SaveAfterIndexId }; int result = iMasterDirectionIndex.AddMasterDirectionIndex(masterDirectionIndex); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "MasterDirectionIndex added successfully."; } else if (result == -2) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "MasterDirectionIndex alread exists."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding MasterDirectionIndex."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding MasterDirectionIndex."; Utility.WriteLog("AddMasterDirectionIndex", addMasterDirectionIndexRequest, "Error while adding MasterDirectionIndex. (MasterDirectionIndexAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult GetMasterDirectionIndex([FromUri] GetMasterDirectionIndexRequest getMasterDirectionIndexRequest) { var responses = new Responses(); try { if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } if (getMasterDirectionIndexRequest == null) { getMasterDirectionIndexRequest = new GetMasterDirectionIndexRequest(); } if (getMasterDirectionIndexRequest.PageSize == null) { getMasterDirectionIndexRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]); } var masterDirectionIndex = new MasterDirectionIndex() { MasterDirectionIndexId = getMasterDirectionIndexRequest.MasterDirectionIndexId, MasterDirectionId = getMasterDirectionIndexRequest.MasterDirectionId, MasterDirectionChapterId = getMasterDirectionIndexRequest.MasterDirectionChapterId, SearchText = getMasterDirectionIndexRequest.SearchText, IsActive = getMasterDirectionIndexRequest.IsActive, PageNumber = getMasterDirectionIndexRequest.PageNumber, PageSize = Convert.ToInt32(getMasterDirectionIndexRequest.PageSize), IsPagingRequired = (getMasterDirectionIndexRequest.PageNumber != null) ? true : false, OrderBy = getMasterDirectionIndexRequest.OrderBy, OrderByDirection = getMasterDirectionIndexRequest.OrderByDirection }; var masterDirectionIndexes = iMasterDirectionIndex.GetMasterDirectionIndex(masterDirectionIndex).OrderBy(x => x.SortId).ToList(); var masterDirectionIndexList = new List <GetMasterDirectionIndexResponse>(); foreach (var masterDirectionIndexDetail in masterDirectionIndexes) { masterDirectionIndexList.Add(new GetMasterDirectionIndexResponse() { MasterDirectionIndexId = Convert.ToInt32(masterDirectionIndexDetail.MasterDirectionIndexId), MasterDirectionChapterId = Convert.ToInt32(masterDirectionIndexDetail.MasterDirectionChapterId), IndexNo = masterDirectionIndexDetail.IndexNo, IndexName = masterDirectionIndexDetail.IndexName, IndexContent = masterDirectionIndexDetail.IndexContent, SortId = masterDirectionIndexDetail.SortId, IsActive = Convert.ToBoolean(masterDirectionIndexDetail.IsActive), CreatedBy = masterDirectionIndexDetail.CreatedBy, TotalPageCount = masterDirectionIndexDetail.TotalPageCount, TotalRecord = masterDirectionIndexDetail.TotalRecord }); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "MasterDirectionIndex retrieved successfully"; responses.Response = masterDirectionIndexList; } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while retrieving MasterDirectionIndex."; Utility.WriteLog("GetMasterDirectionIndex", getMasterDirectionIndexRequest, "Error while retrieving MasterDirectionIndex. (MasterDirectionOfFEMASubModuleDetailUserController)", ex.ToString()); } return(Ok(responses)); }