Ejemplo n.º 1
0
        public IHttpActionResult UpdateRulesSubIndex(UpdateRulesSubIndexRequest updateRulesSubIndexRequest)
        {
            var responses = new Responses();

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

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

                var rulesSubIndex = new RulesSubIndex()
                {
                    SubIndexId          = updateRulesSubIndexRequest.SubIndexId,
                    IndexId             = updateRulesSubIndexRequest.IndexId,
                    SubIndexNo          = updateRulesSubIndexRequest.SubIndexNo,
                    SubIndexName        = updateRulesSubIndexRequest.SubIndexName,
                    SubIndexContent     = updateRulesSubIndexRequest.SubIndexContent,
                    SaveAfterSubIndexId = updateRulesSubIndexRequest.SaveAfterSubIndexId,
                    ModifiedBy          = Utility.UserId
                };
                int result = iRulesSubIndex.UpdateRulesSubIndex(rulesSubIndex);

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

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

                case -3:
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "RulesSubIndex 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("UpdateRulesSubIndex", updateRulesSubIndexRequest, "Error while updating fema subindex. (RulesSubIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IEnumerable <RulesSubIndex> GetRulesSubIndex(RulesSubIndex RulesSubIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var RulesSubIndexes = dataContext.RulesSubIndexGet(RulesSubIndex.SubIndexId, RulesSubIndex.IndexId, RulesSubIndex.RulesId, Utility.TrimString(RulesSubIndex.SearchText), RulesSubIndex.IsActive, RulesSubIndex.PageNumber, RulesSubIndex.PageSize, RulesSubIndex.IsPagingRequired, Utility.TrimString(RulesSubIndex.OrderBy), Utility.TrimString(RulesSubIndex.OrderByDirection), totalPageCount, totalRecord).ToList();

                var RulesSubIndexList = new List <RulesSubIndex>();
                foreach (var RulesSubIndexDetail in RulesSubIndexes)
                {
                    RulesSubIndexList.Add(new RulesSubIndex()
                    {
                        SubIndexId      = RulesSubIndexDetail.RulesSubIndexId,
                        IndexId         = RulesSubIndexDetail.IndexId,
                        SubIndexNo      = RulesSubIndexDetail.RuleSubIndexNo,
                        SubIndexName    = RulesSubIndexDetail.RuleSubIndexName,
                        SubIndexContent = RulesSubIndexDetail.SubIndexContent,
                        SortId          = RulesSubIndexDetail.SortId,
                        IsActive        = RulesSubIndexDetail.Isactive,
                        TotalPageCount  = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord     = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(RulesSubIndexList);
            }
        }
        public int DeleteRulesSubIndex(RulesSubIndex RulesSubIndex)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.RulesSubIndexDelete(RulesSubIndex.SubIndexId, RulesSubIndex.IndexId, RulesSubIndex.ModifiedBy, result);

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

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

                return(Convert.ToInt32(result.Value));
            }
        }
Ejemplo n.º 5
0
        public IHttpActionResult AddRulesSubIndex(AddRulesSubIndexRequest addRulesSubIndexRequest)
        {
            var responses = new Responses();

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

                var rulesSubIndex = new RulesSubIndex()
                {
                    IndexId             = addRulesSubIndexRequest.IndexId,
                    SubIndexNo          = addRulesSubIndexRequest.SubIndexNo,
                    SubIndexName        = addRulesSubIndexRequest.SubIndexName,
                    SubIndexContent     = addRulesSubIndexRequest.SubIndexContent,
                    SaveAfterSubIndexId = addRulesSubIndexRequest.SaveAfterSubIndexId
                };
                int result = iRulesSubIndex.AddRulesSubIndex(rulesSubIndex);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "RulesSubIndex added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "RulesSubIndex 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("AddRulesSubIndex", addRulesSubIndexRequest, "Error while adding fema subindex. (RulesSubIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
Ejemplo n.º 6
0
        public IHttpActionResult GetRulesSubIndex([FromUri] GetRulesSubIndexRequest getRulesSubIndexRequest)
        {
            var responses = new Responses();

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

                if (getRulesSubIndexRequest == null)
                {
                    getRulesSubIndexRequest = new GetRulesSubIndexRequest();
                }

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

                var rulesSubIndex = new RulesSubIndex()
                {
                    SubIndexId       = getRulesSubIndexRequest.SubIndexId,
                    IndexId          = getRulesSubIndexRequest.IndexId,
                    SearchText       = getRulesSubIndexRequest.SearchText,
                    IsActive         = getRulesSubIndexRequest.IsActive,
                    PageNumber       = getRulesSubIndexRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getRulesSubIndexRequest.PageSize),
                    IsPagingRequired = (getRulesSubIndexRequest.PageNumber != null) ? true : false,
                    OrderBy          = getRulesSubIndexRequest.OrderBy,
                    OrderByDirection = getRulesSubIndexRequest.OrderByDirection
                };
                var rulesSubIndexes = iRulesSubIndex.GetRulesSubIndex(rulesSubIndex);

                var rulesSubIndexList = new List <GetRulesSubIndexResponse>();
                foreach (var rulesSubIndexDetail in rulesSubIndexes)
                {
                    rulesSubIndexList.Add(new GetRulesSubIndexResponse()
                    {
                        SubIndexId      = Convert.ToInt32(rulesSubIndexDetail.SubIndexId),
                        IndexId         = Convert.ToInt32(rulesSubIndexDetail.IndexId),
                        SubIndexNo      = rulesSubIndexDetail.SubIndexNo,
                        SubIndexName    = rulesSubIndexDetail.SubIndexName,
                        SubIndexContent = rulesSubIndexDetail.SubIndexContent,
                        SortId          = rulesSubIndexDetail.SortId,
                        IsActive        = Convert.ToBoolean(rulesSubIndexDetail.IsActive),
                        CreatedBy       = rulesSubIndexDetail.CreatedBy,
                        TotalPageCount  = rulesSubIndexDetail.TotalPageCount,
                        TotalRecord     = rulesSubIndexDetail.TotalRecord
                    });
                }

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

                Utility.WriteLog("GetRulesSubIndex", getRulesSubIndexRequest, "Error while retrieving fema subindex. (RulesSubIndexAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }