Esempio n. 1
0
        public static ProjectEnvironmentMap Add(ProjectEnvironmentMap instance)
        {
            using (ES1AutomationEntities context = new ES1AutomationEntities())
            {
                var map = (from m in context.ProjectEnvironmentMaps
                                 where m.ProjectId == instance.ProjectId &&
                                 (m.EnvironmentId == instance.EnvironmentId)
                           select m).FirstOrDefault<ProjectEnvironmentMap>();
                if(map!=null)
                {
                    return map;
                }
                else
                {
                    ProjectEnvironmentMap p = context.ProjectEnvironmentMaps.Add(instance);
                    context.SaveChanges();
                    return p;
                }

            }
        }
Esempio n. 2
0
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="ProductEnvironmentMap"/> converted from <see cref="ProductEnvironmentMapDTO"/>.</param>
partial         static void OnEntity(this ProjectEnvironmentMapDTO dto, ProjectEnvironmentMap entity);
Esempio n. 3
0
        /// <summary>
        /// Converts this instance of <see cref="ProductEnvironmentMapDTO"/> to an instance of <see cref="ProductEnvironmentMap"/>.
        /// </summary>
        /// <param name="dto"><see cref="ProductEnvironmentMapDTO"/> to convert.</param>
        public static ProjectEnvironmentMap ToEntity(this ProjectEnvironmentMapDTO dto)
        {
            if (dto == null) return null;

            var entity = new ProjectEnvironmentMap();

            entity.MapId = dto.MapId;
            entity.ProjectId = dto.ProjectId;
            entity.EnvironmentId = dto.EnvironmentId;

            dto.OnEntity(entity);

            return entity;
        }