Exemplo n.º 1
0
        public async Task <ShopBridgeItemModel> Create(ShopBridgeItemModel model)
        {
            DBContext.Set <ShopBridgeItemModel>().Add(model);
            await DBContext.SaveChangesAsync();

            return(model);
        }
Exemplo n.º 2
0
        public async Task <Product> AddNewProduct(Product product)
        {
            _myDBContext.Set <Product>().Add(product);

            await _myDBContext.SaveChangesAsync();

            return(product);
        }
Exemplo n.º 3
0
        public async virtual Task <T> AddAsync(T entity)
        {
            _context.Set <T>().Add(entity);
            await _context.SaveChangesAsync();

            return(entity);
        }
    public IEnumerable <TModel> Get <TModel>(
        Expression <Func <TEntity, bool> > predicate,
        params Expression <Func <TEntity, object> >[] includes)
    {
        var result = _context.Set <TEntity>()
                     .Where(predicate);

        if (includes != null)
        {
            foreach (var include in includes)
            {
                result = result.Include(include);
            }
        }

        return(_mapper.Map <IList <TModel> >(result));
    }
Exemplo n.º 5
0
        /// <summary>
        /// Forward the request to the appropriate external data source
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private async Task <List <EconomicRelease> > FillExternalRequest(EconomicReleaseRequest request)
        {
            var client = GetClient(request);

            if (client == null)
            {
                _logger.Error($"ERB: Could not find specified data source {request.DataSource}");
                RaiseEvent(Error, this, new ErrorArgs(-1, $"ERB: Could not find specified data source {request.DataSource}"));
                return(new List <EconomicRelease>());
            }

            var data = await client.RequestData(request.FromDate, request.ToDate).ConfigureAwait(false);

            //save the data we got
            try
            {
                using (var context = new MyDBContext())
                {
                    var dbSet = context.Set <EconomicRelease>();
                    foreach (var release in data)
                    {
                        //the data we get might be a duplicate and we want the latest values of everything, so we can't just insert
                        dbSet.AddOrUpdate(x => new { x.Name, x.Country, x.DateTime }, release);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "ERB: Could not save data");
            }

            //Filter the data if necessary
            if (request.Filter != null)
            {
                data = data.AsQueryable().Where(request.Filter).ToList();
            }

            _logger.Info($"ERB returning {data?.Count} items from {client.Name}");

            return(data);
        }
Exemplo n.º 6
0
        private async Task <List <Dividend> > FillExternalRequest(DividendRequest request)
        {
            var client = GetClient(request);

            if (client == null)
            {
                _logger.Error($"DivB: Could not find specified data source {request.DataSource}");
                RaiseEvent(Error, this, new ErrorArgs(-1, $"DivB: Could not find specified data source {request.DataSource}"));
                throw new Exception("Could not find specified data source {request.DataSource}");
            }

            var data = await client.RequestData(request).ConfigureAwait(false);

            //save the data we got
            try
            {
                using (var context = new MyDBContext())
                {
                    var dbSet = context.Set <Dividend>();
                    foreach (var dividend in data)
                    {
                        //the data we get might be a duplicate and we want the latest values of everything, so we can't just insert
                        dbSet.AddOrUpdate(x => new { x.ExDate, x.Symbol }, dividend);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "DivB: Could not save data");
            }

            _logger.Info($"DivB returning {data?.Count} items from {client.Name}");

            return(data);
        }
Exemplo n.º 7
0
 public NationResponsitory(MyDBContext context) : base(context)
 {
     nationEntity = context.Set <Nation>();
 }
Exemplo n.º 8
0
 public BonusResponsitory(MyDBContext context) : base(context)
 {
     bonusEntinty = context.Set <Bonus>();
 }
 public DisciplineResponsitory(MyDBContext context) : base(context)
 {
     disciplinesEntity = context.Set <Discipline>();
 }
 public ShopRepository(MyDBContext ctx)
 {
     _ctx   = ctx;
     _dbSet = _ctx.Set <T>();
 }
Exemplo n.º 11
0
 public IEnumerable <T> GetAll2()
 {
     return(_context.Set <T>().ToList());
 }
Exemplo n.º 12
0
 public AdFormResponsitory(MyDBContext context) : base(context)
 {
     formEntity = context.Set <Forms>();
 }
Exemplo n.º 13
0
 // GET: Customers/Create
 public IActionResult Create()
 {
     ViewData["TipoMembresiaId"] = new SelectList(_context.Set <TipoMembresia>(), "Id", "Id");
     return(View());
 }
 public RegisterResponsitory(MyDBContext context) : base(context)
 {
     registerEntity = context.Set <Register>();
 }
Exemplo n.º 15
0
 public ComplainResponsitory(MyDBContext context) : base(context)
 {
     compalinEntity = context.Set <Complain>();
 }
 public AdToabroadResponsitory(MyDBContext context) : base(context)
 {
     toabroadsEntity = context.Set <Toabroad>();
 }
Exemplo n.º 17
0
 public FormResponsitory(MyDBContext context) : base(context)
 {
     formBoEntiry = context.Set <Forms>();
 }
Exemplo n.º 18
0
 public BaseRepository(MyDBContext db)
 {
     this.db  = db;
     entities = db.Set <T>();
 }
Exemplo n.º 19
0
 // GET: GroupInfos/Create
 public IActionResult Create()
 {
     ViewData["GroupId"]     = new SelectList(_context.Set <Group>(), "GroupId", "GroupId");
     ViewData["StudentAuId"] = new SelectList(_context.Students, "StudentAuId", "FirstName");
     return(View());
 }
Exemplo n.º 20
0
        public void Add(T item)
        {
            try
            {
                db.Set <T>().Add(item);
            }
            catch (DbEntityValidationException dbValEx)
            {
                var outputLines = new StringBuilder();
                foreach (var eve in dbValEx.EntityValidationErrors)
                {
                    outputLines.AppendFormat("{0}: Entity of type '{ 1}' in state '{ 2}' has the following validation errors:"
                                             , DateTime.Now, eve.Entry.Entity.GetType().Name, eve.Entry);

                    foreach (var ve in eve.ValidationErrors)
                    {
                        outputLines.AppendFormat("- Property: '{ 0}', Error: '{ 1}'"
                                                 , ve.PropertyName, ve.ErrorMessage);
                    }
                }

                //Tools.Notify(this, outputLines.ToString(),"error");
                throw new DbEntityValidationException(string.Format("Validation errorsrn{0}", outputLines.ToString()), dbValEx);
            }
        }
Exemplo n.º 21
0
 // GET: MoviesController2/Create
 public IActionResult Create()
 {
     ViewData["GeneroId"] = new SelectList(_context.Set <Genero>(), "Id", "Nombre");
     return(View());
 }
Exemplo n.º 22
0
 public FileResponsitory(MyDBContext context) : base(context)
 {
     fileEntity = context.Set <Files>();
 }
Exemplo n.º 23
0
 public int Count(Func <T, bool> predicate)
 {
     return(context.Set <T>().Where(predicate).Count());
 }
Exemplo n.º 24
0
 public UserMoveResponsitory(MyDBContext context) : base(context)
 {
     userMovesEntiry = context.Set <UserMove>();
 }
Exemplo n.º 25
0
 public ImageProductResponsitory(MyDBContext context) : base(context)
 {
     imgproductEntity = context.Set <ImageProducts>();
 }
Exemplo n.º 26
0
 public AdFileResponsitory(MyDBContext context, IFormFileResponsitory formFileResponsitory) : base(context)
 {
     fileEntity             = context.Set <Files>();
     m_formFileResponsitory = formFileResponsitory;
 }
Exemplo n.º 27
0
 public AdUserResponsitory(MyDBContext context, IHashPass hashPass) : base(context)
 {
     userEntity = context.Set <Users>();
     m_hashPass = hashPass;
 }
Exemplo n.º 28
0
 public DangBoResponsitory(MyDBContext context) : base(context)
 {
     dangBoEntiry = context.Set <DangBo>();
 }
Exemplo n.º 29
0
 public StatisticalResponsitory(MyDBContext context) : base(context)
 {
     userEntity = context.Set <Users>();
 }
Exemplo n.º 30
0
 public void Add(T item)
 {
     db.Set <T>().Add(item);
     Save();
 }