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 }));
        }
示例#3
0
 public IEnumerable <TaskResponse> Invoke()
 {
     return(taskRepository
            .AsQueryable()
            .Select(
                task => new TaskResponse(
                    task.Id.ToString(),
                    task.Title,
                    task.Description)));
 }
示例#4
0
        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 }));
        }
示例#6
0
        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);
        }
示例#7
0
        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);
                }
            });
        }
示例#10
0
 public IActionResult GetAll()
 {
     _logger.LogInformation("Get All stories");
     return(Ok(_storyRepository.AsQueryable().ToList()));
 }
示例#11
0
        public IActionResult Index()
        {
            var posts = postsRepository.AsQueryable().ToList();

            return(View(posts));
        }
示例#12
0
 public List <InventoryItem> Get() =>
 _inventoryItemRepository.AsQueryable().OrderBy(x => x.Manufacturer).ThenBy(x => x.Model).ToList();
示例#13
0
 public IEnumerable <User> GetAll()
 {
     return(_userRepository.AsQueryable().ToList <User>().WithoutPasswords());
 }
示例#14
0
 public IEnumerable <User> GetAll()
 {
     return(_users.AsQueryable().ToList());
 }
示例#15
0
 public IQueryable <Organisation> GetAll()
 {
     return(_repo.AsQueryable());
 }
示例#16
0
 public IActionResult Index() => Json(_category.AsQueryable());
 public List <CarItem> Get() =>
 _carItemRepository.AsQueryable().ToList();
示例#18
0
 public IList <Recipe> Get()
 {
     return(_recipeRepository.AsQueryable().ToList());
 }