Example #1
0
        public Statu GetStatuForTargetId(int id)
        {
            using var context = new NuevoContext();
            var data = context.Status.FirstOrDefault(u => u.TargetId == id);

            if (data == null)
            {
                Statu newStatu = new Statu
                {
                    IsSendAnEmail = false,
                    CheckDateTime = DateTime.Now,
                    TargetId      = id,
                    Code          = "Not Checked Yet",
                };
                context.Set <Statu>().Add(newStatu);
                context.SaveChanges();
                return(newStatu);
            }
            return(data);
        }
Example #2
0
 public void Update(T obj)
 {
     using var context = new NuevoContext();
     context.Set <T>().Update(obj);
     context.SaveChanges();
 }
Example #3
0
 public List <T> GetList()
 {
     using var context = new NuevoContext();
     return(context.Set <T>().ToList());
 }
Example #4
0
 public T GetItem(int id)
 {
     using var context = new NuevoContext();
     return(context.Set <T>().Find(id));
 }
Example #5
0
 public void Delete(T obj)
 {
     using var context = new NuevoContext();
     context.Set <T>().Remove(obj);
     context.SaveChanges();
 }
Example #6
0
 public void Add(T obj)
 {
     using var context = new NuevoContext();
     context.Set <T>().Add(obj);
     context.SaveChanges();
 }