You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
849 B

namespace Model;
public class NounoursManager
{
private INounoursStore nounoursStore;
private IEmailService emailService;
public NounoursManager(INounoursStore nounoursStore, IEmailService emailService)
{
this.nounoursStore = nounoursStore;
this.emailService = emailService;
}
public async Task<bool> AddNewNounours(Nounours nounours)
{
var result = await nounoursStore.Add(nounours);
if(result == null) return false;
try
{
await emailService.AskConfirmation(nounours);
}
catch
{
bool removed = await nounoursStore.Remove(nounours);
if(!removed) throw new Exception("this should not happen...");
return false;
}
return true;
}
}