mardi 9 juillet 2019

C# Implementing inteface [on hold]

I would like to implement interface if it is possible, but can't do it myself.

I have two methods:

    public async Task<ActionResult> Send([FromBody] EmailDto email)
    {
        //send email
    }

    public async Task<ActionResult> SendMany([FromBody] EmailManyDto email)
    {
        //send email
    }

and I have two classes:

public class EmailDto 
{
    public string Recipient { get; set; }
    public string Content { get; set; }
    public string Subject { get; set; }
}

public class EmailManyDto
{
    public List<string> Recipients { get; set; }
    public string Content { get; set; }
    public string Subject { get; set; }
}

I would like to merge these two endpoints into one endpoint. I think I should implement the most general interface as possible - IEnumerable to receive recipients.

Generaly I need to refactor this code someway.

Aucun commentaire:

Enregistrer un commentaire