public async Task <IActionResult> CreateGroup([FromBody] GroupDTO group) { var claims = Request.GetJwtClaims(); if (!claims.IsValidLogin()) { return(claims.Get401Result()); } if (claims.IsLecture || claims.Admin) { var oldGroup = _mongoRepositoryGroup.FindOne(x => x.GroupName.Equals(group.GroupName.ToLower())); var gTemp = string.Empty; var groups = _mongoRepositoryGroup.AsQueryable().ToList(); if (groups.Count == 0) { var g = new Group() { GroupId = @group.GroupId, GroupName = @group.GroupName, Assignemts = new List <Assignment>() { } }; await _mongoRepositoryGroup.InsertOneAsync(g); return(Ok(new { status = true, message = "successful request", data = @group })); } foreach (var grp in groups) { if (!grp.GroupName.ToLower().Equals(group.GroupName.ToLower())) { gTemp = grp.GroupName; } } if (gTemp != string.Empty) { var g = new Group() { GroupId = @group.GroupId, GroupName = @group.GroupName, Assignemts = new List <Assignment>() { } }; await _mongoRepositoryGroup.InsertOneAsync(g); return(Ok(new { status = true, message = "successful request", data = @group })); } else { return(Ok(new { status = false, message = $"Group name {@group.GroupName} already exist", data = @group })); } } return(Ok(new { status = false, message = "Request to be performed by a lecture or admin ", data = "" })); }
public IActionResult GetAll() { var claims = Request.GetJwtClaims(); if (!claims.IsValidLogin()) { return(claims.Get401Result()); } if (!claims.IsLecture) { return(Ok(new { status = false, message = "Request to be done by Lecture", data = "" })); } var allPatient = _mongoRepositoryStudents.AsQueryable().ToList(); return(Ok(new { status = true, message = "successful request", data = allPatient })); }
public IEnumerable <TaskResponse> Invoke() { return(taskRepository .AsQueryable() .Select( task => new TaskResponse( task.Id.ToString(), task.Title, task.Description))); }
public object GetRawData(int machineID, string startTime, string endTime) { var start = DateTime.Parse(startTime, CultureInfo.CurrentCulture, DateTimeStyles.None); var end = DateTime.Parse(endTime, CultureInfo.CurrentCulture, DateTimeStyles.None); var model = _rowDataRepository.AsQueryable().Select(x => new { x.MachineID, x.RPM, x.CreatedDateTime }).OrderByDescending(x => x.CreatedDateTime).ToList().Where(x => x.MachineID == machineID && x.CreatedDateTime >= start && x.CreatedDateTime <= end).ToList(); // var model = _rowDataRepository.AsQueryable().Select(x => new {x.MachineID, x.RPM, x.CreatedDateTime }).OrderByDescending(x=>x.CreatedDateTime).ToList(); return(model); }
public IActionResult GetAll() { var claims = Request.GetJwtClaims(); if (!claims.IsValidLogin()) { return(claims.Get401Result()); } var allDoctors = _mogoRepositoryLecture.AsQueryable().ToList(); return(Ok(new { status = true, message = "successful request", data = allDoctors })); }
public async Task <IEnumerable <Person> > Get(string lastName) { //var people = _peopleRepository.FilterBy( // filter => filter.FirstName == lastName, // projection => projection.FirstName //); var x = await _peopleRepository.FindByIdAsync(new System.Guid("bd619420-3ce3-4a49-a89c-b67320730cbd")); var people = _peopleRepository.AsQueryable().ToList(); return(people); }
public async Task <List <TodoDTO> > GetTodosAsync(GetTodoQuery filter = null, PaginationFilter paginationFilter = null) { var queryable = _todoRepository.AsQueryable(); if (paginationFilter == null) { var check = await queryable.Include(x => x.Tag).ToListAsync(); return(check.ConvertTo().ToList()); } queryable = AddFiltersOnQuery(filter, queryable); var skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize; var listTodo = await queryable.Include(x => x.Tag).Skip(skip).Take(paginationFilter.PageSize).ToListAsync(); return(listTodo.ConvertTo().ToList()); }
private (string, string) CheckIfGroupExist(string grpName) { var g = string.Empty; var i = string.Empty; var groups = _mongoRepositoryGroup.AsQueryable().ToList(); foreach (var group in groups) { if (group.GroupName.ToLower().Equals(grpName.ToLower()) || group.GroupId.Equals(grpName)) { g = group.GroupName; i = group.GroupId; } } return(g, i); }
private void AddAuthors() { Task.Run(async() => { if (!_authorRepository.AsQueryable().Any()) { var createAuthors = new List <Author>(); for (int i = 0; i < 100000; i++) { createAuthors.Add(new Author { Name = $"Author {i}", CreatedOn = DateTime.Now.AddMinutes(i % 2), ShortBio = "Short bio", BirthDate = DateTime.Now.AddYears(-20) }); } await _authorRepository.InsertManyAsync(createAuthors); } }); }
public IActionResult GetAll() { _logger.LogInformation("Get All stories"); return(Ok(_storyRepository.AsQueryable().ToList())); }
public IActionResult Index() { var posts = postsRepository.AsQueryable().ToList(); return(View(posts)); }
public List <InventoryItem> Get() => _inventoryItemRepository.AsQueryable().OrderBy(x => x.Manufacturer).ThenBy(x => x.Model).ToList();
public IEnumerable <User> GetAll() { return(_userRepository.AsQueryable().ToList <User>().WithoutPasswords()); }
public IEnumerable <User> GetAll() { return(_users.AsQueryable().ToList()); }
public IQueryable <Organisation> GetAll() { return(_repo.AsQueryable()); }
public IActionResult Index() => Json(_category.AsQueryable());
public List <CarItem> Get() => _carItemRepository.AsQueryable().ToList();
public IList <Recipe> Get() { return(_recipeRepository.AsQueryable().ToList()); }