/// <summary>
 /// The method returns a list of filtered entities
 /// </summary>
 /// <param name="predicate">Filtering predicate</param>
 /// <returns>List of entities</returns>
 public IEnumerable <AspNetUsers> Get(Func <AspNetUsers, bool> predicate)
 {
     using (DbContext context = new DbContext())
     {
         return(context.AspNetUsers.Where(u => u.ContragentId != null).ToList().Where(predicate).ToList());
     }
 }
 /// <summary>
 /// The method returns an entity by id
 /// </summary>
 /// <param name="id">Id of the entity</param>
 /// <returns>The entity</returns>
 public AspNetUsers Get(int id)
 {
     using (DbContext context = new DbContext())
     {
         return(context.AspNetUsers.FirstOrDefault(c => c.ContragentId == id));
     }
 }
 /// <summary>
 /// The method returns a list of all entities
 /// </summary>
 /// <returns>List of all entities</returns>
 public List <AspNetUsers> Get()
 {
     using (DbContext context = new DbContext())
     {
         return(context.AspNetUsers.Where(u => u.ContragentId != null).ToList());
     }
 }
Esempio n. 4
0
 /// <summary>
 /// The method returns a list of filtered entities
 /// </summary>
 /// <param name="predicate">Filtering predicate</param>
 /// <returns>List of entities</returns>
 public IEnumerable <Offer> Get(Func <Offer, bool> predicate)
 {
     using (DbContext context = new DbContext())
     {
         List <Offer> offers = context.Offers.Where(predicate).ToList();
         return(offers);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// The method returns a list of all entities
 /// </summary>
 /// <returns>List of all entities</returns>
 public List <Offer> Get()
 {
     using (DbContext context = new DbContext())
     {
         List <Offer> offers = context.Offers.Where(o => o.OfrAuditRd == null).ToList();
         return(offers);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// The method returns an entity by id
 /// </summary>
 /// <param name="id">Id of the entity</param>
 /// <returns>The entity</returns>
 public Offer Get(int id)
 {
     using (DbContext context = new DbContext())
     {
         Offer offer = context.Offers.FirstOrDefault(o => o.OfrId == id);
         return(offer);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// The method removes an entity from the storage
        /// </summary>
        /// <param name="entity">The entity</param>
        public void Delete(Offer entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException();
            }

            using (DbContext context = new DbContext())
            {
                context.Offers.Remove(entity);
                context.SaveChangesAsync();
            }
        }
        /// <summary>
        /// The method removes an entity from the storage
        /// </summary>
        /// <param name="entity">The entity</param>
        public async void Delete(AspNetUsers entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException();
            }

            using (DbContext context = new DbContext())
            {
                if (string.IsNullOrEmpty(entity.Id))
                {
                    context.AspNetUsers.Remove(entity);
                }

                await context.SaveChangesAsync();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// The method writes an entity to the storage
        /// </summary>
        /// <param name="entity">The entity</param>
        public void Save(Offer entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException();
            }

            if (entity.OfrId == 0)
            {
                entity.OfrAuditCd = DateTime.Now;
            }

            entity.OfrAuditMd = DateTime.Now;
            using (DbContext context = new DbContext())
            {
                context.Offers.Add(entity);
                context.SaveChangesAsync();
            }
        }
 public ContragentsRepository()
 {
     _context = new DbContext();
 }