Ejemplo n.º 1
0
 /// <summary>
 /// Add project template to database
 /// </summary>
 public void Add()
 {
     using (ProjectTemplatesContext db = new ProjectTemplatesContext())
     {
         db.ProjectTemplates.Add(new Repository.Entities.ProjectTemplate
         {
             Name = Name,
             Data = Data
         });
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deletes project template by id
 /// </summary>
 /// <param name="id">Id</param>
 public static void Delete(int id)
 {
     using (ProjectTemplatesContext db = new ProjectTemplatesContext())
     {
         Repository.Entities.ProjectTemplate t = db.ProjectTemplates.FirstOrDefault(x => x.Id == id);
         if (t != null)
         {
             db.ProjectTemplates.Remove(t);
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Update project template
 /// </summary>
 public void Update()
 {
     using (ProjectTemplatesContext db = new ProjectTemplatesContext())
     {
         Repository.Entities.ProjectTemplate p = db.ProjectTemplates.FirstOrDefault(x => x.Id == Id);
         if (p != null)
         {
             p.Name = Name;
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Check project templates existance by name
 /// </summary>
 /// <param name="name">Name</param>
 /// <returns></returns>
 public static bool Exists(string name)
 {
     try
     {
         using (ProjectTemplatesContext db = new ProjectTemplatesContext())
         {
             Repository.Entities.ProjectTemplate p = db.ProjectTemplates.FirstOrDefault(x => x.Name.Equals(name));
             return(p != null);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Logger.Error(ex, "Failed to get projects templates list from database.");
         return(false);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets list of project templates
        /// </summary>
        /// <returns></returns>
        public static List <ProjectTemplate> GetList()
        {
            List <ProjectTemplate> result = new List <ProjectTemplate>();

            try
            {
                using (ProjectTemplatesContext db = new ProjectTemplatesContext())
                {
                    foreach (Repository.Entities.ProjectTemplate p in db.ProjectTemplates.OrderBy(x => x.Name))
                    {
                        result.Add(new ProjectTemplate(p.Id, p.Name, p.Data));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Logger.Error(ex, "Failed to get projects templates list from database.");
            }

            return(result);
        }