コード例 #1
0
        /// <summary>
        /// Adds the or update.
        /// </summary>
        /// <param name="groupMemberId">The group member identifier.</param>
        /// <param name="scheduleId">The schedule identifier.</param>
        /// <param name="locationId">The location identifier.</param>
        /// <returns></returns>
        public GroupMemberAssignment AddOrUpdate(int groupMemberId, int scheduleId, int?locationId = null)
        {
            GroupMemberAssignment groupMemberAssignment = null;

            // Check to see if a GroupMemberAssignment exists for the GroupMember and Scheudle
            groupMemberAssignment = Queryable()
                                    .Where(x => x.GroupMemberId == groupMemberId)
                                    .Where(x => x.ScheduleId == scheduleId)
                                    .FirstOrDefault();

            // If not then create one
            if (groupMemberAssignment == null)
            {
                groupMemberAssignment = new GroupMemberAssignment
                {
                    GroupMemberId = groupMemberId,
                    ScheduleId    = scheduleId,
                    LocationId    = locationId
                };

                this.Add(groupMemberAssignment);
            }
            else
            {
                groupMemberAssignment.LocationId = locationId;
            }

            return(groupMemberAssignment);
        }
コード例 #2
0
 /// <summary>
 /// Clones this GroupMemberAssignment object to a new GroupMemberAssignment object
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param>
 /// <returns></returns>
 public static GroupMemberAssignment Clone(this GroupMemberAssignment source, bool deepCopy)
 {
     if (deepCopy)
     {
         return(source.Clone() as GroupMemberAssignment);
     }
     else
     {
         var target = new GroupMemberAssignment();
         target.CopyPropertiesFrom(source);
         return(target);
     }
 }
コード例 #3
0
 /// <summary>
 /// Copies the properties from another GroupMemberAssignment object to this GroupMemberAssignment object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this GroupMemberAssignment target, GroupMemberAssignment source)
 {
     target.Id                      = source.Id;
     target.ForeignGuid             = source.ForeignGuid;
     target.ForeignKey              = source.ForeignKey;
     target.GroupMemberId           = source.GroupMemberId;
     target.LocationId              = source.LocationId;
     target.ScheduleId              = source.ScheduleId;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid                    = source.Guid;
     target.ForeignId               = source.ForeignId;
 }