public ReturnMessageModel CreateResourceSubscriber(ResourceSubscriberModel rsbModel) { try { var rRow = _context.ResourceSubscribers.Where(x => x.SubscriberId == rsbModel.SubscriberId).FirstOrDefault(); if (rRow == null) { rRow = new ResourceSubscriber(); } rRow.SubscriberId = rsbModel.SubscriberId; rRow.FirstName = rsbModel.FirstName; rRow.MiddleName = rsbModel.MiddleName; rRow.LastName = rsbModel.LastName; rRow.MembershipNumber = rsbModel.MembershipNumber; rRow.IsStudent = rsbModel.IsStudent; rRow.IsEmployee = rsbModel.IsEmployee; rRow.IsActive = rsbModel.IsActive; rRow.CreatedBy = rsbModel.CreatedBy; rRow.CreatedDate = rsbModel.CreatedDate; rRow.ModifiedBy = rsbModel.ModifiedBy; rRow.ModifiedDate = rsbModel.ModifiedDate; if (rRow.SubscriberId == 0) { rRow.CreatedBy = WebSecurity.CurrentUserId; rRow.CreatedDate = System.DateTime.Now; _context.ResourceSubscribers.Add(rRow); _context.SaveChanges(); } else { rRow.ModifiedBy = WebSecurity.CurrentUserId; rRow.ModifiedDate = System.DateTime.Now; _context.ResourceSubscribers.Attach(rRow); _context.Entry(rRow).State = EntityState.Modified; _context.SaveChanges(); } rModel.Msg = "Subscriber Saved Successfully"; rModel.Success = true; return(rModel); } catch (Exception ex) { rModel.Msg = "Subscriber Saved Failed"; rModel.Success = false; return(rModel); } }
private void Connect(IStreamSubscriber subscriber) { var newResourceSubscriber = new ResourceSubscriber { Resource = Context.ActorOf(Props.Create <ResourceActor>(subscriber.Consumer, LoggerFactory.CreateLogger <ResourceActor>())), StreamSubscriber = subscriber }; _subscribers[subscriber.Consumer.Id] = newResourceSubscriber; newResourceSubscriber.Resource.Tell(new ConnectMessage() { Id = subscriber.Consumer.Id, Consumer = subscriber.Consumer }); }