Exemplo n.º 1
0
        public MasterServiceCode UpdateServiceCode(MasterServiceCode serviceCode, DateTime CurrentDate)
        {
            try
            {
                if (serviceCode.MasterServiceCodeModifiers.Any(x => x.DeletedDate == CurrentDate || x.UpdatedDate == CurrentDate))
                {
                    foreach (var item in serviceCode.MasterServiceCodeModifiers.Where(x => x.UpdatedDate == CurrentDate || x.DeletedDate == CurrentDate))
                    {
                        _context.Entry(item).State = EntityState.Modified;
                    }
                }

                if (serviceCode.MasterServiceCodeModifiers.Any(x => x.CreatedDate == CurrentDate))
                {
                    _context.MasterServiceCodeModifiers.AddRange(serviceCode.MasterServiceCodeModifiers.Where(x => x.CreatedDate == CurrentDate));
                }
                _context.Entry(serviceCode).State = EntityState.Modified;
                _context.SaveChanges();
            }
            catch (Exception)
            {
            }
            return(serviceCode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes multiple entities which are found using filter.
        /// </summary>
        /// <param name="filter">Filter expression for filtering the entities.</param>
        public virtual void Delete(Expression <Func <T, bool> > filter)
        {
            IQueryable <T> dbQuery = SelectQuery(filter);

            dbQuery.AsNoTracking().ToList().ForEach(item => context.Entry(item).State = EntityState.Deleted);
        }