using Domain.SeedWork;
using Framework.DataType;
using Resources.Messages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.Aggregates.Stores;

public class Store : Entity
{
    public Store()
    {
        ////**********
    }

    private Store(string name, string address, string mobile, int score)
    {
        Name = name;
        Address = address;
        Mobile = mobile;
        Score = score;
    }


    public string Name { get; private set; }
    public string Address { get; private set; }
    public string Mobile { get; private set; }
    public int Score { get; private set; }

    public static Store Create(string name, string address, string mobile, int score)
    {
        if (!mobile.IsValidMobile())
        {
            var error =
                string.Format(Errors.Invalid, Resources.DataDictionary.CellPhonenumber);

            throw new InvalidDataException(error);
        }

        var store = new Store(
            name: name.Fix() ?? "",
            address: address.Fix() ?? "",
            mobile: mobile,
            score: score);

        return store;
    }

    public void Update(string name, string address, string mobile, int score)
    {
        if (!mobile.IsValidMobile())
        {
            var error =
                string.Format(Errors.Invalid, Resources.DataDictionary.CellPhonenumber);

            throw new InvalidDataException(error);
        }

        Name = name.Fix() ?? "";
        Address = address.Fix() ?? "";
        Mobile = mobile;
        Score = score;

        SetUpdateDateTime();
    }
}
