public IEnumerable <AuthorFAQDetail> GetAuthorFAQDetail(AuthorFAQDetail authorFAQDetail)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var authorFAQDetails = dataContext.AuthorFAQDetailGet(authorFAQDetail.AuthorFAQDetailId, authorFAQDetail.AuthorFAQId, Utility.TrimString(authorFAQDetail.SearchText), authorFAQDetail.IsActive, authorFAQDetail.PageNumber, authorFAQDetail.PageSize, authorFAQDetail.IsPagingRequired, Utility.TrimString(authorFAQDetail.OrderBy), Utility.TrimString(authorFAQDetail.OrderByDirection), totalPageCount, totalRecord).ToList();

                var authorFAQDetailList = new List <AuthorFAQDetail>();
                foreach (var authorFAQDetailDetail in authorFAQDetails)
                {
                    authorFAQDetailList.Add(new AuthorFAQDetail()
                    {
                        AuthorFAQDetailId = authorFAQDetailDetail.AuthorFAQDetailId,
                        AuthorFAQId       = authorFAQDetailDetail.AuthorFAQId,
                        SubTopicId        = authorFAQDetailDetail.SubTopicId,
                        SubTopicName      = authorFAQDetailDetail.SubTopicName,
                        IsActive          = authorFAQDetailDetail.IsActive,
                        TotalPageCount    = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord       = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(authorFAQDetailList);
            }
        }
        public IHttpActionResult UpdateAuthorFAQDetail(UpdateAuthorFAQDetailRequest updateAuthorFAQDetailRequest)
        {
            var responses = new Responses();

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

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

                var authorFAQDetail = new AuthorFAQDetail()
                {
                    AuthorFAQDetailId = updateAuthorFAQDetailRequest.AuthorFAQDetailId,
                    AuthorFAQId       = updateAuthorFAQDetailRequest.AuthorFAQId,
                    SubTopicId        = updateAuthorFAQDetailRequest.SubTopicId,
                    ModifiedBy        = Utility.UserId
                };
                int result = iAuthorFAQDetail.UpdateAuthorFAQDetail(authorFAQDetail);

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

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

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

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

                Utility.WriteLog("UpdateAuthorFAQDetail", updateAuthorFAQDetailRequest, "Error while updating authorfaqdetail. (AuthorFAQDetailAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public int DeleteAuthorFAQDetail(AuthorFAQDetail authorFAQDetail)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.AuthorFAQDetailDelete(authorFAQDetail.AuthorFAQDetailId, authorFAQDetail.ModifiedBy, result);

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

                dataContext.AuthorFAQDetailAdd(authorFAQDetail.AuthorFAQId, authorFAQDetail.SubTopicId, authorFAQDetail.CreatedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
        public IHttpActionResult AddAuthorFAQDetail(AddAuthorFAQDetailRequest addAuthorFAQDetailRequest)
        {
            var responses = new Responses();

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

                var authorFAQDetail = new AuthorFAQDetail()
                {
                    AuthorFAQId = addAuthorFAQDetailRequest.AuthorFAQId,
                    SubTopicId  = addAuthorFAQDetailRequest.SubTopicId,
                    CreatedBy   = Utility.UserId
                };
                int result = iAuthorFAQDetail.AddAuthorFAQDetail(authorFAQDetail);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "AuthorFAQDetail added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "AuthorFAQDetail alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding authorfaqdetail.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding authorfaqdetail.";

                Utility.WriteLog("AddAuthorFAQDetail", addAuthorFAQDetailRequest, "Error while adding authorfaqdetail. (AuthorFAQDetailAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
        public IHttpActionResult GetAuthorFAQDetail([FromUri] GetAuthorFAQDetailRequest getAuthorFAQDetailRequest)
        {
            var responses = new Responses();

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

                if (getAuthorFAQDetailRequest == null)
                {
                    getAuthorFAQDetailRequest = new GetAuthorFAQDetailRequest();
                }

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

                var authorFAQDetail = new AuthorFAQDetail()
                {
                    AuthorFAQDetailId = getAuthorFAQDetailRequest.AuthorFAQDetailId,
                    AuthorFAQId       = getAuthorFAQDetailRequest.AuthorFAQId,
                    SearchText        = getAuthorFAQDetailRequest.SearchText,
                    IsActive          = getAuthorFAQDetailRequest.IsActive,
                    PageNumber        = getAuthorFAQDetailRequest.PageNumber,
                    PageSize          = Convert.ToInt32(getAuthorFAQDetailRequest.PageSize),
                    IsPagingRequired  = (getAuthorFAQDetailRequest.PageNumber != null) ? true : false,
                    OrderBy           = getAuthorFAQDetailRequest.OrderBy,
                    OrderByDirection  = getAuthorFAQDetailRequest.OrderByDirection
                };
                var authorFAQDetails = iAuthorFAQDetail.GetAuthorFAQDetail(authorFAQDetail);

                var authorFAQDetailList = new List <GetAuthorFAQDetailResponse>();
                foreach (var authorFAQDetailDetail in authorFAQDetails)
                {
                    authorFAQDetailList.Add(new GetAuthorFAQDetailResponse()
                    {
                        AuthorFAQDetailId = Convert.ToInt32(authorFAQDetailDetail.AuthorFAQDetailId),
                        SubTopicId        = authorFAQDetailDetail.SubTopicId,
                        SubTopicName      = authorFAQDetailDetail.SubTopicName,
                        IsActive          = Convert.ToBoolean(authorFAQDetailDetail.IsActive),
                        CreatedBy         = authorFAQDetailDetail.CreatedBy,
                        TotalPageCount    = authorFAQDetailDetail.TotalPageCount,
                        TotalRecord       = authorFAQDetailDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "AuthorFAQDetail retrieved successfully";
                responses.Response    = authorFAQDetailList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving authorfaqdetail.";

                Utility.WriteLog("GetAuthorFAQDetail", getAuthorFAQDetailRequest, "Error while retrieving authorfaqdetail. (AuthorFAQDetailAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }