Пример #1
0
        ///<summary>
        ///Elimina una tarea
        ///</summary>
        ///<param name="id">identificador de la tarea</param>
        public void DeleteJob(string id)
        {
            BackgroundJob.Delete(id);
            var rel = _context.JobRepository.FirstOrDefault(item => item.IdJob.Equals(id));

            if (rel == null)
            {
                var list = _context.JobRepository.Where(item => item.IdJob.Contains($"{id}_") && item.FechaEjecucion > DateTime.Now).ToList();
                if (list.Count > 1)
                {
                    foreach (var job in list)
                    {
                        if (job.IdJob.Split("_")[0].Equals(id))
                        {
                            rel = job;
                        }
                    }
                }
                else
                {
                    rel = list[0];
                }
            }
            _context.Entry(rel).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
            _context.SaveChanges();
        }
        ///<summary>
        ///Elimina una tarea
        ///</summary>
        ///<param name="id">identificador de la tarea</param>
        public void DeleteJob(string id)
        {
            BackgroundJob.Delete(id);
            var rel = _context.JobRepository.FirstOrDefault(item => item.IdJob.Equals(id));

            _context.Entry(rel).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
            _context.SaveChanges();
        }