public void Save(DataMessage message) { try { var context = new VontobelDBConnection(); var newMessage = new Message { CreatedOn = DateTime.Now, Id = Guid.NewGuid().ToString("N"), IsDeleted = false, MessageContent = new MessageContent { Content = message.Content, CreatedOn = DateTime.Now }, }; foreach (var param in message.Parameters) { newMessage.MessageParameters.Add(new MessageParameter { Id = Guid.NewGuid().ToString("N"), IsDeleted = false, Key = param.Key, Value = param.Value }); } context.Messages.Add(newMessage); context.SaveChanges(); } catch (Exception ex) { throw; } }
public void UpdateSubscriptionLog(IList <string> partnerIds, int eventCode, string protocolType, string messageId) { if (partnerIds == null || string.IsNullOrEmpty(protocolType)) { return; } try { var context = new VontobelDBConnection(); var subscribedPartners = (from p in context.Partners join ps in context.PartnerSubscriptions on p equals ps.Partner where ps.MessageProtocol.Name == protocolType && ps.Event.Code == eventCode && partnerIds.Contains(p.Id) select ps); subscribedPartners.ToList().ForEach( x => context.SubscriptionMessageLogs.Add( new SubscriptionMessageLog { Id = Guid.NewGuid().ToString("N"), PartnerSubscriptionId = x.Id, Picked = 1, MessageId = messageId })); context.SaveChanges(); } catch (Exception e) { throw; } }
public void MarkAsPicked(string messageId) { var context = new VontobelDBConnection(); context.Messages.Where(x => x.Id == messageId).FirstOrDefault().Picked = 1; context.SaveChanges(); }