Пример #1
0
        public ActionResult GetAllAllergyByUserId()
        {
            APIJsonResult result = new APIJsonResult();
            var           userId = User.Claims.SingleOrDefault(x => x.Type == "UserId") != null?User.Claims.SingleOrDefault(x => x.Type == "UserId").Value : null;

            int UserId = 0;

            Int32.TryParse(userId, out UserId);
            if (UserId == 0)
            {
                result.success = false;
                result.Msg.Add("NoUser");
                return(Ok(result));
            }
            result.success = true;
            result.Access  = true;
            List <AllergyViewModel> queryAllergy = (from a in _context.Set <Allergy>().ToList()
                                                    select new AllergyViewModel
            {
                Id = a.Id,
                Name = a.Name,
                Selected = _context.Set <MedicationAllergyMap>().Where(s => s.UserId == UserId && s.AllergyId == a.Id).Count() > 0
            }).ToList();

            var data = queryAllergy;

            result.data = data;
            return(Ok(result));
        }
        public async Task <T> InsertAsync <T>(T entity) where T : BaseEntity
        {
            await _dbContext.Set <T>().AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(entity);
        }
Пример #3
0
 public PatientMedicationAPIController(LibraryDbContext context)
 {
     _context         = context;
     _user            = _context.Set <User>();
     _medication      = _context.Set <Medication>();
     _days            = _context.Set <Days>();
     _medicinesLookUp = _context.Set <MedicinesLookUp>();
 }
Пример #4
0
        public PastSurgicalHistoryController(LibraryDbContext context)
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");

            _context                  = context;
            _PastSurgicalHistory      = _context.Set <PastSurgicalHistory>();
            _PastSurgicalHistoryImage = _context.Set <PastSurgicalHistoryImage>();
            Configuration             = builder.Build();
        }
Пример #5
0
        public LookUpsController(LibraryDbContext context)
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");

            _context         = context;
            _medicinesLookUp = _context.Set <MedicinesLookUp>();
            _days            = _context.Set <Days>();
            _user            = _context.Set <User>();
            Configuration    = builder.Build();
        }
Пример #6
0
        public async Task <IEnumerable <T> > GetAllAsync(Expression <Func <T, bool> > filter = null, Func <IQueryable <T>, IOrderedQueryable <T> > orderBy = null, string includeProperties = null, bool trackChanges = false)
        {
            IQueryable <T> query = _libraryDbContext.Set <T>();

            if (!trackChanges)
            {
                _libraryDbContext.Set <T>().AsNoTracking();
            }
            if (filter != null)
            {
                query = query.Where(filter);
            }
            //include properties separadas por comas
            if (includeProperties != null)
            {
                foreach (var includeProperty in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    query = query.Include(includeProperty);
                }
            }
            if (orderBy != null)
            {
                query = orderBy(query);
            }

            return(await query.ToListAsync());
        }
Пример #7
0
        public AuthController(LibraryDbContext context)
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");

            _localizer      = new JsonStringLocalizerApi();
            _context        = context;
            _users          = _context.Set <User>();
            _gustUserDevice = _context.Set <GustUserDevice>();
            _users          = _context.Set <User>();
            Configuration   = builder.Build();
        }
Пример #8
0
        public async Task Add_Entity_IncreaseRecord <TEntity>(TEntity entity)
            where TEntity : class, IIdentificable
        {
            var previousCount = await CountEntities <TEntity>();

            _context.Set <TEntity>().Add(entity);
            await _context.SaveChangesAsync();

            var currentCount = await CountEntities <TEntity>();

            Assert.Equal(previousCount + 1, currentCount);
        }
Пример #9
0
        public ActionResult GetSurgicalHistoryById([FromBody] int Id)
        {
            APIJsonResult result = new APIJsonResult();

            var userId = User.Claims.SingleOrDefault(x => x.Type == "UserId") != null?User.Claims.SingleOrDefault(x => x.Type == "UserId").Value : null;

            int UserId = 0;

            Int32.TryParse(userId, out UserId);
            if (UserId == 0)
            {
                result.success = false;
                result.Msg.Add("NoUser");
                return(Ok(result));
            }

            result.data = (from a in _PastSurgicalHistory.Where(a => a.UserId == UserId && a.Id == Id)
                           select new
            {
                a.Id,
                a.Name,
                SurgicalDate = PublicFunctions.ConvertToTimestamp(a.SurgicalDate),
                a.UserId,
                Images = (from image in _context.Set <PastSurgicalHistoryImage>().Where(f => f.SurgicalId == a.Id)
                          select new
                {
                    image = Configuration["Doctors:Url"] + "/" + "Upload/SurgicalHistory/" + UserId + "/" + image.Image,
                }).ToList()
            }).FirstOrDefault();

            return(Ok(result));
        }
Пример #10
0
 public virtual void Add(T entity)
 {
     _context.Set <T>().Add(entity);
     _context.SaveChanges();
 }
 public IEnumerable <Book> GetAllBooks()
 {
     return(_dbContext.Set <Book>().OrderBy(x => x.Author).ThenBy(x => x.Title));
 }
Пример #12
0
 public Repository(IDbFactory dbFactory)
 {
     _dbFactory = dbFactory;
     _dbContext = this._dbFactory.Init();
     _dbSet     = _dbContext.Set <T>();
 }
Пример #13
0
 public PublicApiController(LibraryDbContext context, IHostingEnvironment appEnvironment)
 {
     _context   = context;
     _bloodType = _context.Set <BloodType>();
 }
Пример #14
0
 public async Task <T> GetItemByIdAsync(long id) => await _dbContext.Set <T>().FindAsync(id);
Пример #15
0
 public virtual T GetById(Guid id)
 {
     return(_dbContext.Set <T>().Find(id));
 }
Пример #16
0
 public int Count(Func <T, bool> predicate)
 {
     return(_context.Set <T>().Where(predicate).Count());
 }
Пример #17
0
 public GenericRepository()
 {
     this._context = new LibraryDbContext();
     table         = _context.Set <T>();
 }
 public T Add(T entity)
 {
     _dbContext.Set <T>().Add(entity);
     return(entity);
 }
Пример #19
0
 public int Count(Func <T, bool> predicate) => _context.Set <T>().Where(predicate).Count();
Пример #20
0
 public IEnumerable <T> GetAll()
 {
     return(_context.Set <T>());
 }
Пример #21
0
 public AllergyAPIController(LibraryDbContext context)
 {
     _context = context;
     _allergy = _context.Set <Allergy>();
     _medicationAllergyMap = _context.Set <MedicationAllergyMap>();
 }
Пример #22
0
 private IQueryable <T> ApplySpecification <T>(ISpecification <T> spec) where T : BaseEntity
 {
     return(SpecificationEvaluator <T> .GetQuery(dbContext.Set <T>().AsQueryable(), spec));
 }
Пример #23
0
 public int Count(Func <T, bool> predicate)
 {
     // use Set<>() if we use generic tyles or we dont know what _context have
     return(_context.Set <T>().Where(predicate).Count());
 }
Пример #24
0
 public IQueryable <T> GetQuery()
 {
     return(dBContext.Set <T>().AsQueryable());
 }
 public Task AddAsync(T entity)
 {
     return(Task.Run(() => libraryDbContext.Set <T>().AddAsync(entity)));
 }
Пример #26
0
 public BookReaderRepository(LibraryDbContext dbContext) : base(dbContext)
 {
     _bookReaders = dbContext.Set <BookReader>();
 }
Пример #27
0
 public Repository(LibraryDbContext context)
 {
     Context = context;
     DbSet   = context.Set <TEntity>();
 }
 public IEnumerable <Book> GetAllAvailableBooks()
 {
     return(_dbContext.Set <Book>().OrderBy(x => x.Name).ThenBy(x => x.Author));
 }
Пример #29
0
 public GenericRepository(LibraryDbContext _context)
 {
     this._context = _context;
     table         = _context.Set <T>();
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandRepositoryBase{T, TId}"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 protected CommandRepositoryBase(LibraryDbContext context)
 {
     _context = context;
     _dataSet = _context.Set <T>();
 }