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); }
public PatientMedicationAPIController(LibraryDbContext context) { _context = context; _user = _context.Set <User>(); _medication = _context.Set <Medication>(); _days = _context.Set <Days>(); _medicinesLookUp = _context.Set <MedicinesLookUp>(); }
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(); }
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(); }
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()); }
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(); }
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); }
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)); }
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)); }
public Repository(IDbFactory dbFactory) { _dbFactory = dbFactory; _dbContext = this._dbFactory.Init(); _dbSet = _dbContext.Set <T>(); }
public PublicApiController(LibraryDbContext context, IHostingEnvironment appEnvironment) { _context = context; _bloodType = _context.Set <BloodType>(); }
public async Task <T> GetItemByIdAsync(long id) => await _dbContext.Set <T>().FindAsync(id);
public virtual T GetById(Guid id) { return(_dbContext.Set <T>().Find(id)); }
public int Count(Func <T, bool> predicate) { return(_context.Set <T>().Where(predicate).Count()); }
public GenericRepository() { this._context = new LibraryDbContext(); table = _context.Set <T>(); }
public T Add(T entity) { _dbContext.Set <T>().Add(entity); return(entity); }
public int Count(Func <T, bool> predicate) => _context.Set <T>().Where(predicate).Count();
public IEnumerable <T> GetAll() { return(_context.Set <T>()); }
public AllergyAPIController(LibraryDbContext context) { _context = context; _allergy = _context.Set <Allergy>(); _medicationAllergyMap = _context.Set <MedicationAllergyMap>(); }
private IQueryable <T> ApplySpecification <T>(ISpecification <T> spec) where T : BaseEntity { return(SpecificationEvaluator <T> .GetQuery(dbContext.Set <T>().AsQueryable(), spec)); }
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()); }
public IQueryable <T> GetQuery() { return(dBContext.Set <T>().AsQueryable()); }
public Task AddAsync(T entity) { return(Task.Run(() => libraryDbContext.Set <T>().AddAsync(entity))); }
public BookReaderRepository(LibraryDbContext dbContext) : base(dbContext) { _bookReaders = dbContext.Set <BookReader>(); }
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)); }
public GenericRepository(LibraryDbContext _context) { this._context = _context; table = _context.Set <T>(); }
/// <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>(); }