コード例 #1
0
        public IEnumerable <AuthorFAQ> GetAuthorFAQ(AuthorFAQ authorFAQ)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter totalPageCount = new ObjectParameter("TotalPageCount", typeof(int));
                ObjectParameter totalRecord    = new ObjectParameter("TotalRecord", typeof(int));

                var authorFAQs = dataContext.AuthorFAQGet(authorFAQ.AuthorFAQId, Utility.TrimString(authorFAQ.SearchText), authorFAQ.IsActive, authorFAQ.PageNumber, authorFAQ.PageSize, authorFAQ.IsPagingRequired, Utility.TrimString(authorFAQ.OrderBy), Utility.TrimString(authorFAQ.OrderByDirection), totalPageCount, totalRecord).ToList();

                var authorFAQList = new List <AuthorFAQ>();
                foreach (var authorFAQDetail in authorFAQs)
                {
                    authorFAQList.Add(new AuthorFAQ()
                    {
                        AuthorFAQId    = authorFAQDetail.AuthorFAQId,
                        TopicId        = authorFAQDetail.TopicId,
                        TopicName      = authorFAQDetail.TopicName,
                        IsActive       = authorFAQDetail.IsActive,
                        TotalPageCount = Convert.ToInt32(totalPageCount.Value),
                        TotalRecord    = Convert.ToInt32(totalRecord.Value)
                    });
                }
                return(authorFAQList);
            }
        }
コード例 #2
0
        public IHttpActionResult UpdateAuthorFAQ(UpdateAuthorFAQRequest updateAuthorFAQRequest)
        {
            var responses = new Responses();

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

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

                var authorFAQ = new AuthorFAQ()
                {
                    AuthorFAQId = updateAuthorFAQRequest.AuthorFAQId,
                    TopicId     = updateAuthorFAQRequest.TopicId,
                    ModifiedBy  = Utility.UserId
                };
                int result = iAuthorFAQ.UpdateAuthorFAQ(authorFAQ);

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

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

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

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

                Utility.WriteLog("UpdateAuthorFAQ", updateAuthorFAQRequest, "Error while updating authorfaq. (AuthorFAQAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
コード例 #3
0
        public int DeleteAuthorFAQ(AuthorFAQ authorFAQ)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.AuthorFAQDelete(authorFAQ.AuthorFAQId, authorFAQ.ModifiedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
コード例 #4
0
        public int AddAuthorFAQ(AuthorFAQ authorFAQ)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                ObjectParameter result = new ObjectParameter("Result", typeof(int));

                dataContext.AuthorFAQAdd(authorFAQ.TopicId, authorFAQ.CreatedBy, result);

                return(Convert.ToInt32(result.Value));
            }
        }
コード例 #5
0
        public IHttpActionResult AddAuthorFAQ(AddAuthorFAQRequest addAuthorFAQRequest)
        {
            var responses = new Responses();

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

                var authorFAQ = new AuthorFAQ()
                {
                    TopicId   = addAuthorFAQRequest.TopicId,
                    CreatedBy = Utility.UserId
                };
                int result = iAuthorFAQ.AddAuthorFAQ(authorFAQ);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "AuthorFAQ added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "AuthorFAQ alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding authorfaq.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding authorfaq.";

                Utility.WriteLog("AddAuthorFAQ", addAuthorFAQRequest, "Error while adding authorfaq. (AuthorFAQAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }
コード例 #6
0
        public IHttpActionResult GetAuthorFAQ([FromUri] GetAuthorFAQRequest getAuthorFAQRequest)
        {
            var responses = new Responses();

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

                if (getAuthorFAQRequest == null)
                {
                    getAuthorFAQRequest = new GetAuthorFAQRequest();
                }

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

                var authorFAQ = new AuthorFAQ()
                {
                    AuthorFAQId      = getAuthorFAQRequest.AuthorFAQId,
                    SearchText       = getAuthorFAQRequest.SearchText,
                    IsActive         = getAuthorFAQRequest.IsActive,
                    PageNumber       = getAuthorFAQRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getAuthorFAQRequest.PageSize),
                    IsPagingRequired = (getAuthorFAQRequest.PageNumber != null) ? true : false,
                    OrderBy          = getAuthorFAQRequest.OrderBy,
                    OrderByDirection = getAuthorFAQRequest.OrderByDirection
                };
                var authorFAQs = iAuthorFAQ.GetAuthorFAQ(authorFAQ);

                var authorFAQList = new List <GetAuthorFAQResponse>();
                foreach (var authorFAQDetail in authorFAQs)
                {
                    authorFAQList.Add(new GetAuthorFAQResponse()
                    {
                        AuthorFAQId    = Convert.ToInt32(authorFAQDetail.AuthorFAQId),
                        TopicId        = authorFAQDetail.TopicId,
                        TopicName      = authorFAQDetail.TopicName,
                        IsActive       = Convert.ToBoolean(authorFAQDetail.IsActive),
                        CreatedBy      = authorFAQDetail.CreatedBy,
                        TotalPageCount = authorFAQDetail.TotalPageCount,
                        TotalRecord    = authorFAQDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "AuthorFAQ retrieved successfully";
                responses.Response    = authorFAQList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving authorfaq.";

                Utility.WriteLog("GetAuthorFAQ", getAuthorFAQRequest, "Error while retrieving authorfaq. (AuthorFAQAdminController)", ex.ToString());
            }
            return(Ok(responses));
        }