Exemple #1
0
 /// <summary>
 /// The Delete
 /// </summary>
 /// <param name="entity">The entity<see cref="sysdiagram"/></param>
 /// <returns>The <see cref="ServiceResult"/></returns>
 public ServiceResult Delete(sysdiagram entity)
 {
     try
     {
         _repository.Delete(entity);
         return(new ServiceResult(true));
     }
     catch (Exception ex)
     {
         return(new ServiceResult(false)
         {
             Error = ex.ToString()
         });
     }
 }
        /// <summary>
        /// Converts this instance of <see cref="sysdiagram"/> to an instance of <see cref="sysdiagramDTO"/>.
        /// </summary>
        /// <param name="entity"><see cref="sysdiagram"/> to convert.</param>
        public static sysdiagramDTO ToDTO(this sysdiagram entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new sysdiagramDTO();

            dto.name         = entity.name;
            dto.principal_id = entity.principal_id;
            dto.diagram_id   = entity.diagram_id;
            dto.version      = entity.version;
            dto.definition   = entity.definition;

            entity.OnDTO(dto);

            return(dto);
        }
        /// <summary>
        /// Converts this instance of <see cref="sysdiagramDTO"/> to an instance of <see cref="sysdiagram"/>.
        /// </summary>
        /// <param name="dto"><see cref="sysdiagramDTO"/> to convert.</param>
        public static sysdiagram ToEntity(this sysdiagramDTO dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new sysdiagram();

            entity.name         = dto.name;
            entity.principal_id = dto.principal_id;
            entity.diagram_id   = dto.diagram_id;
            entity.version      = dto.version;
            entity.definition   = dto.definition;

            dto.OnEntity(entity);

            return(entity);
        }
 public virtual sysdiagram CreatesysdiagramFromReader(IDataReader reader)
 {
     sysdiagram item = new sysdiagram();
     try
     {
         if (!reader.IsDBNull(reader.GetOrdinal("name"))) item.name = (string)reader["name"];
         if (!reader.IsDBNull(reader.GetOrdinal("principal_id"))) item.principal_id = (int)reader["principal_id"];
         if (!reader.IsDBNull(reader.GetOrdinal("diagram_id"))) item.diagram_id = (int)reader["diagram_id"];
         if (!reader.IsDBNull(reader.GetOrdinal("version"))) item.version = (int)reader["version"];
         if (!reader.IsDBNull(reader.GetOrdinal("definition"))) item.definition = (byte[])reader["definition"];
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessCreatesysdiagramFromReaderException, ex);
     }
     return item;
 }
 public virtual void Updatesysdiagram(sysdiagram sysdiagram)
 {
     try
     {
         Database database = DatabaseFactory.CreateDatabase();
         DbCommand dbCommand = database.GetStoredProcCommand("spsysdiagramsUpdate");            
         
         database.AddInParameter(dbCommand, "@name", DbType.String, sysdiagram.name);
         database.AddInParameter(dbCommand, "@principal_id", DbType.Int32, sysdiagram.principal_id);
         database.AddInParameter(dbCommand, "@diagram_id", DbType.Int32, sysdiagram.diagram_id);
         database.AddInParameter(dbCommand, "@version", DbType.Int32, sysdiagram.version);
         database.AddInParameter(dbCommand, "@definition", DbType.Binary, sysdiagram.definition);
         
         database.ExecuteNonQuery(dbCommand);
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessUpdatesysdiagramException, ex);
     }
 }
Exemple #6
0
        /// <summary>
        /// The Save
        /// </summary>
        /// <param name="entity">The entity<see cref="sysdiagram"/></param>
        /// <returns>The <see cref="ServiceResult"/></returns>
        public ServiceResult Save(sysdiagram entity)
        {
            try
            {
                if (entity.Identifier == 0)
                {
                    _repository.Add(entity);
                }
                else
                {
                    _repository.Update(entity);
                }

                return(new ServiceResult(true));
            }
            catch (Exception ex)
            {
                return(new ServiceResult(false)
                {
                    Error = ex.ToString()
                });
            }
        }
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="sysdiagram"/> converted from <see cref="sysdiagramDTO"/>.</param>
 static partial void OnEntity(this sysdiagramDTO dto, sysdiagram entity);
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="sysdiagramDTO"/> converted from <see cref="sysdiagram"/>.</param>
 static partial void OnDTO(this sysdiagram entity, sysdiagramDTO dto);
 public void AddTosysdiagrams(sysdiagram sysdiagram)
 {
     base.AddObject("sysdiagrams", sysdiagram);
 }
Exemple #10
0
 public static sysdiagram Createsysdiagram(string name, int principal_id, int diagram_id)
 {
     sysdiagram sysdiagram = new sysdiagram();
     sysdiagram.name = name;
     sysdiagram.principal_id = principal_id;
     sysdiagram.diagram_id = diagram_id;
     return sysdiagram;
 }