namespace Hims.Admin.Utilities
{
    using System;
    using Microsoft.AspNetCore.Mvc;

    /// <inheritdoc />
    /// <summary>
    /// The base controller.
    /// </summary>
    public class BaseController : Controller
    {
        /// <summary>
        /// The success.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <returns>
        /// The <see cref="ObjectResult"/>.
        /// </returns>
        protected ObjectResult Success(object model = null) => this.StatusCode(200, model);

        /// <summary>
        /// The bad request.
        /// </summary>
        /// <returns>
        /// The <see cref="ObjectResult"/>.
        /// </returns>
        protected new ObjectResult BadRequest() => this.StatusCode(400, string.Empty);

        /// <summary>
        /// The bad request.
        /// </summary>
        /// <param name="message">
        /// The message.
        /// </param>
        /// <returns>
        /// The <see cref="ObjectResult"/>.
        /// </returns>
        protected ObjectResult BadRequest(string message) => this.StatusCode(400, message ?? string.Empty);

        /// <summary>
        /// The failed request.
        /// </summary>
        /// <param name="message">
        /// The message.
        /// </param>
        /// <returns>
        /// The <see cref="ObjectResult"/>.
        /// </returns>
        protected ObjectResult Failed(string message) => this.StatusCode(417, message ?? string.Empty);

        /// <summary>
        /// The forbidden request.
        /// </summary>
        /// <param name="message">
        /// The message.
        /// </param>
        /// <returns>
        /// The <see cref="ObjectResult"/>.
        /// </returns>
        protected ObjectResult Forbidden(string message) => this.StatusCode(403, message ?? string.Empty);

        /// <summary>
        /// The server error.
        /// </summary>
        /// <returns>
        /// The <see cref="StatusCodeResult"/>.
        /// </returns>
        protected ObjectResult ServerError() => this.StatusCode(500, string.Empty);

        /// <summary>
        /// The server error.
        /// </summary>
        /// <param name="message">
        /// The message.
        /// </param>
        /// <returns>
        /// The <see cref="StatusCodeResult"/>.
        /// </returns>
        protected ObjectResult ServerError(string message) => this.StatusCode(500, message);

        /// <summary>
        /// The server error.
        /// </summary>
        /// <param name="exception">
        /// The exception.
        /// </param>
        /// <returns>
        /// The <see cref="StatusCodeResult"/>.
        /// </returns>
        protected ObjectResult ServerError(Exception exception) => this.StatusCode(500, exception.Message);
    }
}