public async Task Can_Add_Log() { var now = DateTime.Now; var dbContextOptions = CreateNewContextOptions(); var user = new User(); using (var context = new ApplicationDbContext(dbContextOptions)) { context.Users.Add(user); await context.SaveChangesAsync(); } using (var context = new ApplicationDbContext(dbContextOptions)) { var service = new LogsService(context); service.Add(user.Id, "Message"); await context.SaveChangesAsync(); } using (var context = new ApplicationDbContext(dbContextOptions)) { var log = await context.Logs.FirstAsync(); Assert.True(now < log.Date); Assert.Equal(log.UserId, user.Id); Assert.Equal(log.Message, "Message"); } }
public static void Send(User user, string body, int busId) { var Id = ConverterServices.ConvertGuid(user.Id); var notification = new NotificationDto() { Body = body, UserId = Id }; NotificationPushServices.Push(user.DeviceToken, busId, notification); LogsService.Add(body, Id); }
public static void Send(List <User> users, string body) { foreach (var user in users) { var Id = ConverterServices.ConvertGuid(user.Id); var notification = new NotificationDto() { Body = body, UserId = Id }; NotificationPushServices.Push(user.DeviceToken, notification); LogsService.Add(body, Id); } }