// NotificationCategory cat = db.NotificationCategorys.Where(c => c.Name == category).FirstOrDefault(); //objNotif.NotificationCategoryId = db.NotificationCategorys.Where(c => c.Name == category).FirstOrDefault().NotificationCategoryId; public async Task CreateNotificationAsync(int id, string category) { try { List <string> users = new List <string>(); Notification1 objNotif = new Notification1(); //get all category List <int> catids = db.NotificationCategorys.Where(c => c.Name == category).Select(c => c.NotificationCategoryId).ToList(); foreach (var catid in catids) { //NotificationCategory cat = db.NotificationCategorys.Include(rr.NotificationCatUser).Where(c => c.NotificationCategoryId == catid).FirstOrDefault(); string u = db.NotificationCatUsers.Where(ux => ux.NotificationCategoryId == catid).FirstOrDefault().UserId; objNotif.NotificationCategoryId = catid; objNotif.ObjectId = id; objNotif.NotificationDate = DateTime.Now; db.Configuration.ProxyCreationEnabled = false; db.Notifications.Add(objNotif); db.SaveChanges(); users.Add(u); } SendNoficationAsync(users); } catch (Exception e) { //log.Error(" ERROR mylog - Error while send notification for project " + project.ProjectId + ":" + e.Message + " , stacktrace:" + e.StackTrace); } }
public void Delete(Notification1 Notification) { db.Notifications.Remove(Notification); }
public void Add(Notification1 Notification) { db.Notifications.Add(Notification); }