public IEnumerable <FemaIndex> GetFemaIndex(FemaIndex femaIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var femaIndexes = dataContext.FemaindexGet(femaIndex.IndexId, femaIndex.RegulationId, Utility.TrimString(femaIndex.SearchText), femaIndex.IsActive, femaIndex.PageNumber, femaIndex.PageSize, femaIndex.IsPagingRequired, Utility.TrimString(femaIndex.OrderBy), Utility.TrimString(femaIndex.OrderByDirection), totalPageCount, totalRecord).ToList();

                var femaIndexList = new List <FemaIndex>();
                foreach (var femaIndexDetail in femaIndexes)
                {
                    femaIndexList.Add(new FemaIndex()
                    {
                        IndexId        = femaIndexDetail.Indexid,
                        RegulationId   = femaIndexDetail.Regulationid,
                        IndexNo        = femaIndexDetail.IndexNo,
                        IndexName      = femaIndexDetail.Indexname,
                        IndexContent   = femaIndexDetail.IndexContent,
                        SortId         = femaIndexDetail.SortId,
                        IsActive       = femaIndexDetail.Isactive,
                        TotalPageCount = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord    = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(femaIndexList);
            }
        }
예제 #2
0
        public IHttpActionResult UpdateFemaIndex(UpdateFemaIndexRequest updateFemaIndexRequest)
        {
            var responses = new Responses();

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

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

                var femaIndex = new FemaIndex()
                {
                    IndexId          = updateFemaIndexRequest.IndexId,
                    RegulationId     = updateFemaIndexRequest.RegulationId,
                    IndexNo          = updateFemaIndexRequest.IndexNo,
                    IndexName        = updateFemaIndexRequest.IndexName,
                    IndexContent     = updateFemaIndexRequest.IndexContent,
                    SaveAfterIndexId = updateFemaIndexRequest.SaveAfterIndexId,
                    ModifiedBy       = Utility.UserId
                };
                int result = iFemaIndex.UpdateFemaIndex(femaIndex);

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

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

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

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

                Utility.WriteLog("UpdateFemaIndex", updateFemaIndexRequest, "Error while updating fema index. (FemaIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public int DeleteFemaIndex(FemaIndex femaIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.FemaindexDelete(femaIndex.IndexId, femaIndex.RegulationId, femaIndex.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public int UpdateFemaIndex(FemaIndex femaIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.FemaindexUpdate(femaIndex.IndexId, femaIndex.RegulationId, Utility.TrimString(femaIndex.IndexNo), Utility.TrimString(femaIndex.IndexName), Utility.TrimString(femaIndex.IndexContent), femaIndex.SaveAfterIndexId, femaIndex.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
예제 #5
0
        public IHttpActionResult AddFemaIndex(AddFemaIndexRequest addFemaIndexRequest)
        {
            var responses = new Responses();

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

                var femaIndex = new FemaIndex()
                {
                    RegulationId     = addFemaIndexRequest.RegulationId,
                    IndexNo          = addFemaIndexRequest.IndexNo,
                    IndexName        = addFemaIndexRequest.IndexName,
                    IndexContent     = addFemaIndexRequest.IndexContent,
                    SaveAfterIndexId = addFemaIndexRequest.SaveAfterIndexId
                };
                int result = iFemaIndex.AddFemaIndex(femaIndex);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "FemaIndex added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "FemaIndex alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding fema index.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding fema index.";

                Utility.WriteLog("AddFemaIndex", addFemaIndexRequest, "Error while adding fema index. (FemaIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetFemaIndex([FromUri] GetFemaIndexRequest getFemaIndexRequest)
        {
            var responses = new Responses();

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

                if (getFemaIndexRequest == null)
                {
                    getFemaIndexRequest = new GetFemaIndexRequest();
                }

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

                var femaIndex = new FemaIndex()
                {
                    IndexId          = getFemaIndexRequest.IndexId,
                    RegulationId     = getFemaIndexRequest.RegulationId,
                    SearchText       = getFemaIndexRequest.SearchText,
                    IsActive         = getFemaIndexRequest.IsActive,
                    PageNumber       = getFemaIndexRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getFemaIndexRequest.PageSize),
                    IsPagingRequired = (getFemaIndexRequest.PageNumber != null) ? true : false,
                    OrderBy          = getFemaIndexRequest.OrderBy,
                    OrderByDirection = getFemaIndexRequest.OrderByDirection
                };
                var femaIndexes = iFemaIndex.GetFemaIndex(femaIndex).OrderBy(x => x.SortId).ToList();

                var femaIndexList = new List <GetFemaIndexResponse>();
                foreach (var femaIndexDetail in femaIndexes)
                {
                    femaIndexList.Add(new GetFemaIndexResponse()
                    {
                        IndexId        = Convert.ToInt32(femaIndexDetail.IndexId),
                        RegulationId   = Convert.ToInt32(femaIndexDetail.RegulationId),
                        IndexNo        = femaIndexDetail.IndexNo,
                        IndexName      = femaIndexDetail.IndexName,
                        IndexContent   = femaIndexDetail.IndexContent,
                        SortId         = femaIndexDetail.SortId,
                        IsActive       = Convert.ToBoolean(femaIndexDetail.IsActive),
                        CreatedBy      = femaIndexDetail.CreatedBy,
                        TotalPageCount = femaIndexDetail.TotalPageCount,
                        TotalRecord    = femaIndexDetail.TotalRecord
                    });
                }

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

                Utility.WriteLog("GetFemaIndex", getFemaIndexRequest, "Error while retrieving fema index. (FEMASubModuleDetailUserController)", ex.ToString());
            }
            return(Ok(responses));
        }