/// <summary>
 /// The get by id.
 /// </summary>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <returns>
 /// The <see cref="T"/>.
 /// </returns>
 public virtual T GetById(int id)
 {
     using (var dbcontext = new evadb())
     {
         return(dbcontext.Set <T>().FirstOrDefault(p => p.Id == 1));
     }
 }
 /// <summary>
 /// The get all.
 /// </summary>
 /// <returns>
 /// The <see cref="List"/>.
 /// </returns>
 public virtual List <T> GetAll()
 {
     using (var dbcontext = new evadb())
     {
         return(dbcontext.Set <T>().ToList());
     }
 }
 /// <summary>
 /// The create.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <returns>
 /// The <see cref="T"/>.
 /// </returns>
 public virtual T Create(T entity)
 {
     using (var dbcontext = new evadb())
     {
         T createdEntity = dbcontext.Set <T>().Add(entity);
         dbcontext.SaveChanges();
         return(createdEntity);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// The get all.
 /// </summary>
 /// <returns>
 /// The <see cref="List"/>.
 /// </returns>
 public override List <Project> GetAll()
 {
     using (var dbcontext = new evadb())
     {
         return(dbcontext.Projects
                .Select(e => e)
                .Include("Resources")
                .Include("ChatSubscriptions")
                .ToList());
     }
 }
 /// <summary>
 /// The update.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public virtual bool Update(T entity)
 {
     try
     {
         using (var dbcontext = new evadb())
         {
             dbcontext.Set <T>().AddOrUpdate(entity);
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }