Ejemplo n.º 1
0
 public static Subscriber AddOrUpdateSubscriber(Subscriber instance)
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         Subscriber existingSubscriber = context.Subscribers.Where(s => s.ProjectId == instance.ProjectId && s.UserId == instance.UserId).FirstOrDefault();
         if (null == existingSubscriber)
         {
             context.Subscribers.Add(instance);
             context.SaveChanges();
             return instance;
         }
         return existingSubscriber;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="Subscriber"/> converted from <see cref="SubscriberDTO"/>.</param>
partial         static void OnEntity(this SubscriberDTO dto, Subscriber entity);
Ejemplo n.º 3
0
        /// <summary>
        /// Converts this instance of <see cref="SubscriberDTO"/> to an instance of <see cref="Subscriber"/>.
        /// </summary>
        /// <param name="dto"><see cref="SubscriberDTO"/> to convert.</param>
        public static Subscriber ToEntity(this SubscriberDTO dto)
        {
            if (dto == null) return null;

            var entity = new Subscriber();

            entity.SubscriberId = dto.SubscriberId;
            entity.UserId = dto.UserId;
            entity.ProjectId = dto.ProjectId;
            entity.Description = dto.Description;
            entity.SubscriberType = dto.SubscriberType;
            entity.CreateTime = dto.CreateTime;

            dto.OnEntity(entity);

            return entity;
        }