Пример #1
0
        public async Task <IActionResult> View(Guid id, [FromForm] EventSaveModel input)
        {
            var currentUser = await GetCurrentUser();

            var selected = input.GetSelected();

            var statusChanged = input.Status != Status.Unknown;

            await _database.EditEvent(id, async eventEntry =>
            {
                foreach (var signup in selected)
                {
                    var eventSignup = eventEntry.Signups.Single(s => s.Id == signup);

                    if (statusChanged)
                    {
                        eventSignup.Status = input.Status;
                    }

                    if (input.SendEmail)
                    {
                        var model = new EventStatusModel(
                            eventSignup.User.FullName,
                            eventEntry.Title,
                            await SignupLink(eventSignup.User, eventEntry));

                        await SendEmail(input, model, currentUser, statusChanged, eventSignup);
                    }
                    else if (statusChanged)
                    {
                        eventSignup.AuditLog.Add($"Moved to {input.Status} ", currentUser);
                    }
                }
            });

            return(RedirectToAction(nameof(View), new { id }));
        }
Пример #2
0
 public static Task EditEvent(this MemberContext context, Guid id, Action <Data.Event> action)
 => context.EditEvent(id, e =>
 {
     action(e);
     return(Task.CompletedTask);
 });