public async Task <IDalDataResult <TEntity> > GetAsync(Expression <Func <TEntity, bool> > expression, params Expression <Func <TEntity, object> >[] includes) { Exception exception = null; TEntity entity = null; try { foreach (var item in includes) { Query = Query.Include(item); } IQueryable <TEntity> query = GetAll.Where(expression); if (await query.AnyAsync()) { entity = await query.FirstAsync(); } } catch (Exception ex) { exception = ex; Debug.WriteLine($"--Hata-- {ex.Message}"); } return(new DalDataResult <TEntity>(false, exception, entity)); }
public async Task <IActionResult> GetAll(GetAll query) { var result = await _mediator.Send(query); HttpContext.Response.Headers.Add("X-Total-Count", result.TotalCount.ToString()); return(Ok(result.Products)); }
private Direction?GetRandomValidDirection(Map <T> map, T currentCell, T previousCell, IRandomizer randomizer) { var invalidDirections = new List <Direction>(); var squareDirections = new List <Direction>(); while (invalidDirections.Count + squareDirections.Count < GetAll.ValuesOf <Direction>().Count()) { var direction = randomizer.GetRandomEnumValue(invalidDirections.Union(squareDirections)); if (IsDirectionValid(map, currentCell, direction, previousCell)) { var nextCell = map.GetAdjacentCell(currentCell, direction); //Try to avoid creating squares, but do it if there's no other way if (nextCell.IsOpen && ((nextCell.Sides[direction.Rotate()] && currentCell.Sides[direction.Rotate()]) || (nextCell.Sides[direction.Rotate(false)] && currentCell.Sides[direction.Rotate(false)]))) { squareDirections.Add(direction); } else { return(direction); } } else { invalidDirections.Add(direction); } } return(squareDirections.Any() ? randomizer.GetRandomItem(squareDirections) : (Direction?)null); }
public IActionResult GetTrainFromStation(string idTrain, string StationName) { IAPI api = new GetAll(); ViewBag.train = api.GetTrainFromStation(idTrain, StationName); return(View("GetTrain")); }
public ActionResult MakeAccount(string email, string name, string surname, string password, string phoneNumber) { string response = Request["g-recaptcha-response"]; var json = new WebClient().DownloadString("https://www.google.com/recaptcha/api/siteverify?secret=6Le9eGEUAAAAAJt22PAEWs18klrzAqzEeRnYTlJp&response=" + response); var success = JsonConvert.DeserializeObject <GoogleResponseCaptcha>(json); if (success.success) { IAPI api = new GetAll(); password = EncryptPassword(password); User u = api.GetUser(email); if (u == null) { api.MakeAccount(email, name, surname, password, phoneNumber); Session["user"] = api.GetUser(email); return(View("Index")); } else { ViewBag.error = "An account is already link to this email."; return(View("CreateAccount")); } } else { ViewBag.error = "Captcha error"; return(View("CreateAccount")); } }
private void GetAllCmd(GetAll cmd, bool firstExecution) { if (firstExecution) { Owner = Sender; Requestor = cmd.Requestor; OriginalCommand = cmd.OriginalCommand; TargetCount = cmd.TargetCount; RemainingCount = cmd.TargetCount; Targets = cmd.Targets; TargetCommand = cmd.TargetCommand; ExpectedResponseType = cmd.ExpectedResponseType; TimeoutSeconds = cmd.TimeoutSeconds; TellRequestor = cmd.TellRequestor; GetAllMsg = cmd; Become(Aggregating); } else { TargetCount += cmd.TargetCount; RemainingCount += cmd.TargetCount; } }
public string Save(CourseAssignToTeacher courseAssign) { CourseAssignToTeacher courseAssignTo = GetAll.ToList().Find(ca => ca.CourseId == courseAssign.CourseId && ca.Status); if (courseAssignTo == null) { if (courseAssignToTeacherGateway.Insert(courseAssign) > 0) { return("Saved sucessfully"); } return("Failed to save"); } //CourseAssignToTeacher assignTo = // GetAll.ToList().Find(c => c.CourseId == courseAssign.CourseId && c.TeacherId == courseAssign.TeacherId); //if (assignTo != null) //{ // bool st = assignTo.Status; // if (st) // { // return "Overlaping not allowed during course assign"; // } // if (courseAssignToTeacherGateway.Update(courseAssign) > 0) // { // return "Saved sucessfully"; // } // return "Failed to save"; //} return("Overlaping not allowed!"); }
private void GetAllCmd(GetAll cmd) { // aggregator var agg = Context.ActorOf(Props.Create(() => new AggregateActor()), AggregateActor.GetUniqueName()); // active ids agg.Tell(new AggregateActor.GetAll(Sender, cmd, State.IdsActive.Count, State.Type)); foreach (var activeId in State.IdsActive) { var child = Context.Child(activeId); if (child != ActorRefs.Nobody) { agg.Tell(new AggregateActor.GetAllAdd(child, new GetById(activeId))); } else { agg.Tell(new AggregateActor.ReduceTargetCount()); } } // inactive ids agg.Tell(new AggregateActor.GetAll(Sender, cmd, State.IdsInactive.Count, State.Type)); foreach (var inactiveId in State.IdsInactive) { var child = Context.Child(inactiveId); if (child == ActorRefs.Nobody) { child = CreateEntity(inactiveId); } // get inactive data and deactivate child once it replies agg.Tell(new AggregateActor.GetAllAdd(child, new EntityActor.DeactivateAfter <GetById>(new GetById(inactiveId)))); } }
/// <summary> /// Returns all of the adjacent cells of the specified cell. /// </summary> /// <param name="cell">The desired cell.</param> /// <param name="includeDiagonalCells">True if diagonal adjacent cells should be included (defaults to false).</param> /// <returns>All of the adjacent cells of the specified cell.</returns> public IEnumerable <T> GetAllAdjacentCells(T cell, bool includeDiagonalCells = false) { var cells = GetAll.ValuesOf <Direction>() .Where(direction => GetAdjacentCell(cell, direction) != null) .Select(direction => GetAdjacentCell(cell, direction)).ToList(); if (includeDiagonalCells) { if (GetCell(cell.Row - 1, cell.Column - 1) != null) { cells.Add(GetCell(cell.Row - 1, cell.Column - 1)); } if (GetCell(cell.Row + 1, cell.Column - 1) != null) { cells.Add(GetCell(cell.Row + 1, cell.Column - 1)); } if (GetCell(cell.Row - 1, cell.Column + 1) != null) { cells.Add(GetCell(cell.Row - 1, cell.Column + 1)); } if (GetCell(cell.Row + 1, cell.Column + 1) != null) { cells.Add(GetCell(cell.Row + 1, cell.Column + 1)); } } return(cells); }
private IQueryable <AppUser> GetData(AppUserFilter filter) { var data = GetAll.Where(a => a.IsActive); //Filter if (!string.IsNullOrWhiteSpace(filter.LastName)) { filter.LastName = filter.LastName.Trim(); data = data.Where(a => a.LastName.Contains(filter.LastName)); } if (!string.IsNullOrWhiteSpace(filter.FirstName)) { filter.FirstName = filter.FirstName.Trim(); data = data.Where(a => a.FirstName.Contains(filter.FirstName)); } if (!string.IsNullOrWhiteSpace(filter.MiddleName)) { filter.MiddleName = filter.MiddleName.Trim(); data = data.Where(a => a.MiddleName.Contains(filter.MiddleName)); } if (!string.IsNullOrWhiteSpace(filter.UserName)) { filter.UserName = filter.UserName.Trim(); data = data.Where(a => a.UserName.Contains(filter.UserName)); } //if (!string.IsNullOrWhiteSpace(filter.CreatedBy)) //{ // filter.CreatedBy = filter.CreatedBy.Trim(); // data = data.Where(a => (a.CreatedByAppUser.FirstName + " " // + a.CreatedByAppUser.LastName) // .Trim().Contains(filter.CreatedBy)); //} return(data); }
//public string Save(CourseAssignToTeacher courseAssignToTeacher) //{ // return courseAssignToTeacherGateway.Save(courseAssignToTeacher); //} public string Save(CourseAssignToTeacher courseAssignToTeacher) { CourseAssignToTeacher courseAssignTo = GetAll.ToList().Find(ca => ca.CourseId == courseAssignToTeacher.CourseId); if (courseAssignTo == null) { if (courseAssignToTeacherGateway.Insert(courseAssignToTeacher) > 0) { return("Saved sucessfully"); } return("Failed to save"); } CourseAssignToTeacher assignTo = GetAll.ToList().Find(c => c.CourseId == courseAssignToTeacher.CourseId && c.TeacherId == courseAssignToTeacher.TeacherId); if (assignTo != null) { bool st = assignTo.Status; if (st) { return("Overlapping occured(Course has been assigned to this Teacher Already)"); } if (courseAssignToTeacherGateway.Update(courseAssignToTeacher) > 0) { return("Saved sucessfully"); } return("Failed to save"); } return("Overlapping Occured!(Course has already been Assigned to Another Teacher )"); }
public IActionResult SearchStation() { IAPI api = new GetAll(); ViewBag.s = api.SearchStation(); return(View()); }
public async Task <List <ProductDTO> > Handle(GetAll request, CancellationToken cancellationToken = default) { return(await _context.Products .Include(x => x.Barcodes) .ProjectTo <ProductDTO>(_mapper.ConfigurationProvider) .AsNoTracking() .ToListAsync()); }
public IActionResult GetTrain(string idTrain) { IAPI data = new GetAll(); Train train = data.GetTrain(idTrain); ViewBag.train = train; return(View("GetTrain")); }
public async Task <IEnumerable <TransactionDto> > GetAllAsync(GetAll model) { var transactions = await _transactionsRepository.GetAllAsync(model.UserId, model.FromModifiedDate); var transactionDtos = transactions.Select(x => _mapper.Map <TransactionDto>(x)); return(transactionDtos); }
public Task <IResult <IEnumerable <TModel> > > Handle(GetAll <TModel> request, CancellationToken cancellationToken) { return(Task.Run(() => { return _uow.Execute(db => Result.Success( db.GetCollection <TModel>().FindAll())); }, cancellationToken)); }
public async Task <List <CategoryDto> > Handle(GetAll request, CancellationToken cancellationToken) { // Get All Categories return(_mapper.Map <List <CategoryDto> >( await _context.Categories .Where(a => a.Deleted == false) .ToListAsync(cancellationToken))); }
public async Task <IEnumerable <UpcomingExpenseDto> > GetAllAsync(GetAll model) { var upcomingExpenses = await _upcomingExpensesRepository.GetAllAsync(model.UserId, model.FromModifiedDate); var upcomingExpenseDtos = upcomingExpenses.Select(x => _mapper.Map <UpcomingExpenseDto>(x)); return(upcomingExpenseDtos); }
public async Task <IActionResult> GetAll() { var command = new GetAll(); await DispatchAsync(command); return(Ok(command.Result)); }
public BinaryCell() { Sides = new Dictionary <Direction, bool>(); foreach (Direction direction in GetAll.ValuesOf <Direction>()) { Sides[direction] = false; } }
public async Task <IEnumerable <CategoryDto> > GetAllAsync(GetAll model) { var categories = await _categoriesRepository.GetAllAsync(model.UserId, model.FromModifiedDate); var categoryDtos = categories.Select(x => _mapper.Map <CategoryDto>(x)); return(categoryDtos); }
public async Task <IEnumerable <AccountDto> > GetAllAsync(GetAll model) { var accounts = await _accountsRepository.GetAllAsync(model.UserId, model.FromModifiedDate); var accountDtos = accounts.Select(x => _mapper.Map <AccountDto>(x)); return(accountDtos); }
public async Task <IEnumerable <DebtDto> > GetAllAsync(GetAll model) { var debt = await _debtsRepository.GetAllAsync(model.UserId, model.FromModifiedDate); var debtDtos = debt.Select(x => _mapper.Map <DebtDto>(x)); return(debtDtos); }
public Task <IEnumerable <Product> > Handle(GetAll <Product> query) { if (query == null) { throw Error.ArgumentNull(nameof(query)); } return(repository.GetAll()); }
public void Izvodjac() { List <Izvodjac> izvodjaci = GetAll.GetIzvodjaci(); foreach (var element in izvodjaci) { _viewable.Add(DbModelsToViewable.ConvertToIzvodjacViewable(element)); } }
public void Fonogram() { List <Fonogram> fonogrami = GetAll.GetFonogrami(); foreach (var element in fonogrami) { _viewable.Add(DbModelsToViewable.ConvertToFonogramViewable(element)); } }
public void Album() { List <Album> albumi = GetAll.GetAlbumi(); foreach (var element in albumi) { _viewable.Add(DbModelsToViewable.ConvertToAlbumViewable(element)); } }
public static TeacherInfo[] GetFreeTeachers(int ID_Period, int Para, int DayWeek) { var temp = (Db.Schedule.Where(a => a.DayWeek == DayWeek && a.ID_Period == ID_Period && a.Para == Para).Select(a => new TeacherInfo(a.TeachersRow))).ToArray(); var all = GetAll.Teachers(); return(all.Except(temp, new MyTeacherComparer()).ToArray()); }
public async Task <List <ProductLiDto> > Handle(GetAll request, CancellationToken cancellationToken) { // Get All Products return(_mapper.Map <List <ProductLiDto> >( await _context.Products .Where(a => a.Deleted == false && a.Disabled == false) .Include(x => x.Category) .ToListAsync(cancellationToken))); }
public async Task <IActionResult> Index() { var request = new GetAll { UserId = GetUserId() }; var model = await _mediator.Send(request); return(View(model)); }