public IEnumerable <FemaSubIndex> GetFemaSubIndex(FemaSubIndex femaSubIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var femaSubIndexes = dataContext.FemaSubIndexGet(femaSubIndex.SubIndexId, femaSubIndex.IndexId, femaSubIndex.RegulationId, Utility.TrimString(femaSubIndex.SearchText), femaSubIndex.IsActive, femaSubIndex.PageNumber, femaSubIndex.PageSize, femaSubIndex.IsPagingRequired, Utility.TrimString(femaSubIndex.OrderBy), Utility.TrimString(femaSubIndex.OrderByDirection), totalPageCount, totalRecord).ToList();

                var femaSubIndexList = new List <FemaSubIndex>();
                foreach (var femaSubIndexDetail in femaSubIndexes)
                {
                    femaSubIndexList.Add(new FemaSubIndex()
                    {
                        SubIndexId      = femaSubIndexDetail.FemaSubIndexId,
                        IndexId         = femaSubIndexDetail.IndexId,
                        SubIndexNo      = femaSubIndexDetail.SubIndexNumber,
                        SubIndexName    = femaSubIndexDetail.SubIndexName,
                        SubIndexContent = femaSubIndexDetail.SubIndexContent,
                        SortId          = femaSubIndexDetail.SortId,
                        IsActive        = femaSubIndexDetail.Isactive,
                        TotalPageCount  = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord     = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(femaSubIndexList);
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult UpdateFemaSubIndex(UpdateFemaSubIndexRequest updateFemaSubIndexRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                var femaSubIndex = new FemaSubIndex()
                {
                    SubIndexId          = updateFemaSubIndexRequest.SubIndexId,
                    IndexId             = updateFemaSubIndexRequest.IndexId,
                    SubIndexNo          = updateFemaSubIndexRequest.SubIndexNo,
                    SubIndexName        = updateFemaSubIndexRequest.SubIndexName,
                    SubIndexContent     = updateFemaSubIndexRequest.SubIndexContent,
                    SaveAfterSubIndexId = updateFemaSubIndexRequest.SaveAfterSubIndexId,
                    ModifiedBy          = Utility.UserId
                };
                int result = iFemaSubIndex.UpdateFemaSubIndex(femaSubIndex);

                switch (result)
                {
                case 1:
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "FemaSubIndex updated successfully.";
                    break;

                case -2:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "FemaSubIndex already exists.";
                    break;

                case -3:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "FemaSubIndex doesn't exist.";
                    break;

                default:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while updating fema subindex.";
                    break;
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while updating fema subindex.";

                Utility.WriteLog("UpdateFemaSubIndex", updateFemaSubIndexRequest, "Error while updating fema subindex. (FemaSubIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public int DeleteFemaSubIndex(FemaSubIndex femaSubIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.FemaSubIndexDelete(femaSubIndex.SubIndexId, femaSubIndex.IndexId, femaSubIndex.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public int UpdateFemaSubIndex(FemaSubIndex femaSubIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.FemaSubIndexUpdate(femaSubIndex.SubIndexId, femaSubIndex.IndexId, Utility.TrimString(femaSubIndex.SubIndexNo), Utility.TrimString(femaSubIndex.SubIndexName), Utility.TrimString(femaSubIndex.SubIndexContent), femaSubIndex.SaveAfterSubIndexId, femaSubIndex.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
Exemplo n.º 5
0
        public IHttpActionResult AddFemaSubIndex(AddFemaSubIndexRequest addFemaSubIndexRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var femaSubIndex = new FemaSubIndex()
                {
                    IndexId             = addFemaSubIndexRequest.IndexId,
                    SubIndexNo          = addFemaSubIndexRequest.SubIndexNo,
                    SubIndexName        = addFemaSubIndexRequest.SubIndexName,
                    SubIndexContent     = addFemaSubIndexRequest.SubIndexContent,
                    SaveAfterSubIndexId = addFemaSubIndexRequest.SaveAfterSubIndexId
                };
                int result = iFemaSubIndex.AddFemaSubIndex(femaSubIndex);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "FemaSubIndex added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "FemaSubIndex alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding fema subindex.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding fema subindex.";

                Utility.WriteLog("AddFemaSubIndex", addFemaSubIndexRequest, "Error while adding fema subindex. (FemaSubIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetFemaSubIndex([FromUri] GetFemaSubIndexRequest getFemaSubIndexRequest)
        {
            var responses = new Responses();

            try
            {
                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                if (getFemaSubIndexRequest == null)
                {
                    getFemaSubIndexRequest = new GetFemaSubIndexRequest();
                }

                if (getFemaSubIndexRequest.PageSize == null)
                {
                    getFemaSubIndexRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                }

                var femaSubIndex = new FemaSubIndex()
                {
                    SubIndexId       = getFemaSubIndexRequest.SubIndexId,
                    IndexId          = getFemaSubIndexRequest.IndexId,
                    RegulationId     = getFemaSubIndexRequest.RegulationId,
                    SearchText       = getFemaSubIndexRequest.SearchText,
                    IsActive         = getFemaSubIndexRequest.IsActive,
                    PageNumber       = getFemaSubIndexRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getFemaSubIndexRequest.PageSize),
                    IsPagingRequired = (getFemaSubIndexRequest.PageNumber != null) ? true : false,
                    OrderBy          = getFemaSubIndexRequest.OrderBy,
                    OrderByDirection = getFemaSubIndexRequest.OrderByDirection
                };
                var femaSubIndexes = iFemaSubIndex.GetFemaSubIndex(femaSubIndex).OrderBy(x => x.SortId).ToList();

                var femaSubIndexList = new List <GetFemaSubIndexResponse>();
                foreach (var femaSubIndexDetail in femaSubIndexes)
                {
                    femaSubIndexList.Add(new GetFemaSubIndexResponse()
                    {
                        SubIndexId      = Convert.ToInt32(femaSubIndexDetail.SubIndexId),
                        IndexId         = Convert.ToInt32(femaSubIndexDetail.IndexId),
                        SubIndexNo      = femaSubIndexDetail.SubIndexNo,
                        SubIndexName    = femaSubIndexDetail.SubIndexName,
                        SubIndexContent = femaSubIndexDetail.SubIndexContent,
                        SortId          = femaSubIndexDetail.SortId,
                        IsActive        = Convert.ToBoolean(femaSubIndexDetail.IsActive),
                        CreatedBy       = femaSubIndexDetail.CreatedBy,
                        TotalPageCount  = femaSubIndexDetail.TotalPageCount,
                        TotalRecord     = femaSubIndexDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "FemaSubIndex retrieved successfully";
                responses.Response    = femaSubIndexList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving fema subindex.";

                Utility.WriteLog("GetFemaSubIndex", getFemaSubIndexRequest, "Error while retrieving fema subindex. (FEMASubModuleDetailUserController)", ex.ToString());
            }
            return(Ok(responses));
        }