/// <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(); } } }
/// <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(); } } }
/// <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); } }