Ejemplo n.º 1
0
        public async Task <IActionResult> Post(WebContentPages webContentPages)
        {
            try
            {
                WcmDataAccess _wcmAccess = new WcmDataAccess(_iconfiguration);

                DatabaseResponse response = await _wcmAccess.AddPageContent(webContentPages);

                if (response.ResponseCode == (int)DbReturnValue.CreateSuccess)
                {
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = true,
                        IsDomainValidationErrors = false,
                        Message = EnumExtensions.GetDescription(DbReturnValue.CreateSuccess),
                        ReturnedObject = response.Results
                    }));
                }
                else
                {
                    Log.Error(EnumExtensions.GetDescription(DbReturnValue.RecordExists));

                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = false,
                        IsDomainValidationErrors = false,
                        Message = EnumExtensions.GetDescription(DbReturnValue.RecordExists)
                    }));
                }
            }
            catch (Exception ex)
            {
                Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                return(Ok(new OperationResponse
                {
                    HasSucceeded = false,
                    Message = StatusMessages.ServerError,
                    StatusCode = ((int)ResponseStatus.ServerError).ToString(),
                    IsDomainValidationErrors = false
                }));
            }
        }
Ejemplo n.º 2
0
        public async Task <DatabaseResponse> UpdatePageContent(WebContentPages webContentPage)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@PageId",         SqlDbType.Int),
                    new SqlParameter("@PageContent",    SqlDbType.NVarChar),
                    new SqlParameter("@PageContent_Ar", SqlDbType.NVarChar),
                    new SqlParameter("@UpdatedBy",      SqlDbType.Int),
                    new SqlParameter("@VideoLink",      SqlDbType.NVarChar)
                };

                parameters[0].Value = webContentPage.PageID;
                parameters[1].Value = webContentPage.PageContent;
                parameters[2].Value = webContentPage.PageContent_Ar;
                parameters[3].Value = webContentPage.CreatedBy;
                parameters[4].Value = webContentPage.VideoLink;
                _DataHelper         = new DataAccessHelper("spu_WebPageContent", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt);

                return(new DatabaseResponse {
                    ResponseCode = result, Results = null
                });
            }

            catch (Exception ex)
            {
                Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }