public async Task <IActionResult> PutStatus([FromBody] BusinessStatusChangeModel value)
        {
            try
            {
                await service.ChangeStatus(value);

                return(Ok());
            }
            catch (ArgumentException)
            {
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        public async Task ChangeStatus(BusinessStatusChangeModel model)
        {
            var item = await Task.Run(() => repo.GetSingleById(model.BusinessId));

            if (item is null)
            {
                throw new ArgumentException("Cannot find the business");
            }

            item.Status = model.Status;
            await Task.Run(() => repo.Update(item));

            var message = string.IsNullOrEmpty(model.Message) ? $"The status of your application has been moved to {model.Status}" : $"The status of your application has been moved to {model.Status} and the team commented '{model.Message}'";
            await emailService?.SendEmailAsync(item.Contact1Email, "*****@*****.**", "Business Registration Update", message);
        }