public void Add(NotificationsTrackerDto entity)
        {
            NotificationsTracker tracker = CreateBusinessEntity(entity, true);

            Entities.Add(tracker);
            DataContext.Entry(tracker).State = EntityState.Added;
            DataContext.SaveChanges();
        }
 private void MigrateEntity(NotificationsTrackerDto sourceEntity, NotificationsTracker targetEntity)
 {
     targetEntity.AllocationEntryID = sourceEntity.AllocationEntryID;
     targetEntity.FirstAlertSentOn  = sourceEntity.FirstAlertSentOn;
     targetEntity.SecondAlertSentOn = sourceEntity.SecondAlertSentOn;
     targetEntity.ThirdAlertSentOn  = sourceEntity.ThirdAlertSentOn;
     targetEntity.TrackerID         = sourceEntity.TrackerID;
     targetEntity.UpdateTimeStamp(sourceEntity.LoggedInUserName);
 }
        public void Update(NotificationsTrackerDto entity)
        {
            NotificationsTracker buzEntity = Entities.FirstOrDefault(e => e.TrackerID == entity.TrackerID);

            MigrateEntity(entity, buzEntity);
            buzEntity.UpdateTimeStamp(entity.LoggedInUserName);
            Entities.Add(buzEntity);
            DataContext.Entry(buzEntity).State = EntityState.Modified;
            DataContext.SaveChanges();
        }
        private NotificationsTracker CreateBusinessEntity(NotificationsTrackerDto trackerDto, bool isNewEntity = false)
        {
            NotificationsTracker tracker = new NotificationsTracker
            {
                AllocationEntryID = trackerDto.AllocationEntryID,
                FirstAlertSentOn  = trackerDto.FirstAlertSentOn,
                SecondAlertSentOn = trackerDto.SecondAlertSentOn,
                ThirdAlertSentOn  = trackerDto.ThirdAlertSentOn,
                TrackerID         = trackerDto.TrackerID
            };

            tracker.UpdateTimeStamp(trackerDto.LoggedInUserName, true);

            return(tracker);
        }