using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses
{
	public abstract class ResponseBase
	{
		public int ReturnStatus { get; set; }

		public List<string> ReturnMessage { get; set; } = [];
	}

    public class MobileResponseBase<T>
    {
        public int ReturnStatus { get; set; }
        public List<string> ReturnMessage { get; set; } = [];
        public T? Data { get; set; }

        public static MobileResponseBase<T> Success(T data, string message = "Success") =>
            new() { ReturnStatus = 200, ReturnMessage = [message], Data = data };

        public static MobileResponseBase<T> Failure(string message, int status = 400 ) =>
            new() { ReturnStatus = status, ReturnMessage = [message], Data = default };
    }


    public abstract class TotalRowsResponseBase : ResponseBase
	{
		public int TotalRows { get; set; }
	}

	public abstract class ResponseBase1 : ResponseBase
	{
		public Hashtable ValidationErrors { get; set; } = [];
	}

	public abstract class BaseObjectResponse : ResponseBase
	{
		public string Code { get; set; }
		public string Name { get; set; }
		public EnumStatus Status { get; set; }
		public int SeqId { get; set; }
		public string StatusDetail => Status.GetDescription();
	}

	public class BooleanResponse : ResponseBase
	{
		public bool Value { get; set; }
	}

	public class StringResponse : ResponseBase
	{
		public string Value { get; set; }
	}

	public class IntResponse : ResponseBase
	{
		public int Value { get; set; }
	}

	public class KeywordsFromAudioResponse : ResponseBase
	{
		public List<FoundKeywordItem> FoundKeywords { get; set; }
	}

    public class PagedResult<T>
    {
        public IList<T> Items { get; set; } = [];
        public int TotalCount { get; set; }
		public int PageNumber { get; set; } = 1;
		public int PageSize { get; set; } = 10000;
        public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
        public bool HasNextPage => PageNumber < TotalPages;
        public bool HasPreviousPage => PageNumber > 1;
    }
}