예제 #1
0
파일: Subscriber.cs 프로젝트: wangn6/rep2
 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;
     }
 }
예제 #2
0
파일: Core.DTO.cs 프로젝트: wangn6/rep2
        /// <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);
예제 #3
0
파일: Core.DTO.cs 프로젝트: wangn6/rep2
        /// <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;
        }