Пример #1
0
        public async Task <ArticlesResponseModel> AddArticle(ArticlesInformation articlesInformation)
        {
            // update article using context and returning info using lambdas
            try
            {
                _context.Articles.Add(articlesInformation);
                await _context.SaveChangesAsync();

                List <ArticlesInformation> response = await _context.Articles.Where(x => x.Store_Id == articlesInformation.Store_Id).ToListAsync();

                ArticlesResponseModel articlesResponseModel = ArticlesResponseModel.Map(response);
                return(articlesResponseModel);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #2
0
        public async Task <ArticlesResponseModel> UpdateArticle(ArticlesInformation articlesInformation, ArticlesInformation originalInformation)
        {
            // update article using context and returning info using lambdas
            try
            {
                var updateInfo = ArticlesInformation.MapUpdate(articlesInformation, originalInformation);
                _context.Entry(updateInfo).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                List <ArticlesInformation> _articlesInformation = await _context.Articles.Where(x => x.Id == articlesInformation.Id).ToListAsync();

                ArticlesResponseModel articlesResponseModel = ArticlesResponseModel.Map(_articlesInformation);
                return(articlesResponseModel);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
 public async Task <ArticlesResponseModel> AddArticle(ArticlesInformation articlesInformation)
 {
     return(await _articlesDataSet.AddArticle(articlesInformation));
 }
Пример #4
0
 public async Task <ArticlesResponseModel> UpdateArticle(ArticlesInformation articlesInformation, ArticlesInformation originalInformation)
 {
     return(await _articlesDataSet.UpdateArticle(articlesInformation, originalInformation));
 }