public IActionResult Index() { var payments = _repository.List <Payment>().Where(x => x.UserId == User.Identity.Name).ToList(); if (_repository.List <Category>().Any()) { return(View(payments)); } _repository.Add(new Category("Comida")); _repository.Add(new Category("Carro")); _repository.Add(new Category("Salud")); _repository.Add(new Category("Otro")); return(View(payments)); }
public ServiceResponse <List <T> > List(int page, int pageSize) { var serviceResponseBuilder = new ServiceResponseBuilder <List <T> >(); var result = _repository.List(page, pageSize); return(serviceResponseBuilder.Ok(result)); }
public async Task <bool> Handle(DeleteEntriesRequest message, IOutputPort <DeleteEntriesResponse> outputPort) { try { await Task.Run(() => { Guid[] uids = message.Entries.Select(o => o.Uid).ToArray(); foreach (var relation in _RelationRepo.List(o => uids.Contains(o.EntryUid)).ToArray()) { _RelationRepo.Delete(relation); } foreach (var entry in message.Entries) { _EntryRepo.Delete(entry); } }); outputPort.Handle(new DeleteEntriesResponse(true, null)); return(true); } catch (Exception ex) { outputPort.Handle(new DeleteEntriesResponse(false, ex.ToString())); return(false); } }
public IActionResult Index() { var items = _repository.List(ToDoItemSpecs.All()) .Select(ToDoItemDTO.FromToDoItem); return(View(items)); }
public IActionResult Grid() { var transactions = _repository.List <RawTransaction>(); if (transactions.Any()) { return(View(transactions)); } var items = RawTransactionReader.GetAll( @"C:\Users\Jesus\source\repos\Cashflowio\Cashflowio\tests\Cashflowio.Tests\Assets\CoinKeeper.xlsx"); _repository.AddRange(items); return(View(_repository.List <RawTransaction>())); }
public IActionResult OnGet() { Statuses = new List <SelectListItem> { new SelectListItem { Text = "Active", Value = "0" }, new SelectListItem { Text = "Draft", Value = "1" }, new SelectListItem { Text = "Disabled", Value = "2" } }; try { StartupMessage = _repository.List <Core.Data.StartupMessage>().FirstOrDefault(); } catch (Exception ex) { Log.Error($"StartupMessage.Create.OnGet(): {ex.Message} - {ex.StackTrace}"); } return(Page()); }
public IActionResult List() { var products = _repository.List() .Select(product => _mapper.Map <Product, ProductDTO>(product)); return(Ok(products)); }
public IEnumerable <ToDoItemDTO> GetAll() { var res = _repository.List <ToDoItem>() .Select(ToDoItemDTO.FromToDoItem); return(res); }
public IActionResult Create(int?selectedNotebookId) { if (selectedNotebookId == null) { TempData[nameof(ErrorMessageKey)] = "Notebook not selected. If not exist, please create new and select"; return(RedirectToAction(nameof(Index))); } var allNotebooks = notebookRepository.List().ToList(); var selectedNotebook = allNotebooks.SingleOrDefault(b => b.Id == selectedNotebookId); var allNotesForSelectedNotebook = noteRepository.List() .Where(n => n.Notebook.Id == selectedNotebookId) .Include(n => n.Tags) .AsEnumerable() .Select(n => new NoteViewModel() { Id = n.Id, Title = n.Title, Content = n.Content, NotebookId = n.NotebookId, Tags = string.Join(", ", n.Tags.Select(t => t.Name)), }) .ToList(); var model = new NoteIndexViewModel() { AllNotebooks = allNotebooks, SelectedNotebook = selectedNotebook, AllNotesForSelectedNotebook = allNotesForSelectedNotebook, }; return(View(nameof(Index), model)); }
public async Task <CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int?brandId, int?typeId) { _logger.LogInformation("GetCatalogItems called."); var filterSpecification = new CatalogFilterSpecification(brandId, typeId); var filterPaginatedSpecification = new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId); // the implementation below using ForEach and Count. We need a List. var itemsOnPage = _itemRepository.List(filterPaginatedSpecification).ToList(); var totalItems = _itemRepository.Count(filterSpecification); // Initial implementation itemsOnPage.ForEach(x => { x.PictureUri = _uriComposer.ComposePicUri(x.PictureUri); }); // Adding a reference to use an Azure Storage Blob /* * itemsOnPage.ForEach(x => * { * StorageCredentials credentials = new WindowsAzure.Storage.Auth.StorageCredentials("{YOUR_STORAGE_ACCOUNT_NAME}", "{YOUR_STORAGE_PRIMARY_KEY}"); * CloudStorageAccount storageAccount = new WindowsAzure.Storage.CloudStorageAccount(credentials, true); * Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient = new WindowsAzure.Storage.Blob.CloudBlobClient(storageAccount.BlobStorageUri.PrimaryUri, credentials); * Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob blockblob = new WindowsAzure.Storage.Blob.CloudBlockBlob(new Uri(x.PictureUri)); * var blob = blockblob.OpenReadAsync(); * x.PictureUri = _uriComposer.ComposePicUri(blockblob.Uri.ToString()); * }); */ var vm = new CatalogIndexViewModel() { CatalogItems = itemsOnPage.Select(i => new CatalogItemViewModel() { Id = i.Id, Name = i.Name, PictureUri = i.PictureUri, Price = i.Price }), Brands = await GetBrands(), Types = await GetTypes(), BrandFilterApplied = brandId ?? 0, TypesFilterApplied = typeId ?? 0, PaginationInfo = new PaginationInfoViewModel() { ActualPage = pageIndex, ItemsPerPage = itemsOnPage.Count, TotalItems = totalItems, TotalPages = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString()) } }; vm.PaginationInfo.Next = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "is-disabled" : ""; vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "is-disabled" : ""; return(vm); }
public IActionResult List() { var items = _todoRepository.List() .Select(item => ToDoItemDTO.FromToDoItem(item)); return(Ok(items)); }
public IActionResult List() { var items = _repository.List() .Select(item => _mapper.Map <Tag, TagDTO>(item)); return(Ok(items)); }
public IActionResult List() { var items = _taskRepository.List() .Select(item => TaskModel.ReturnTaskModel(item)); return(Ok(items)); }
public static async Task <T> FirstOrDefault <T>(this IRepository r, ISpecification <T> spec) where T : BaseEntity { var list = await r.List(spec); return(list.FirstOrDefault()); }
public T GetSettings <T>() where T : class, new() { var settings = new T(); var settingsEntities = _repository.List(CommandSettingsPolicy.BySettingsName(settings.GetType().Name)); foreach (PropertyInfo propertyInfo in settings.GetType().GetProperties()) { var settingsEntity = settingsEntities.SingleOrDefault(x => x.Key == propertyInfo.Name); if (settingsEntity != null) { propertyInfo.SetValue(settings, Convert.ChangeType(settingsEntity.Value, propertyInfo.PropertyType)); } } return(settings); }
public async Task <bool> Handle(GetCategoriesRequest message, IOutputPort <GetCategoriesResponse> outputPort) { Category[] categories = null; CategoryRelation[] relations = null; try { await Task.Run(() => { categories = _CatRepo.List(message.Query).ToArray(); if (message.IncludeRelations) { Guid[] catUids = categories.Select(o => o.Uid).ToArray(); relations = _RelRepo.List(o => catUids.Contains(o.ParentUid) || catUids.Contains(o.ChildUid)).ToArray(); } }); outputPort.Handle(new GetCategoriesResponse(categories, relations, true, null)); return(true); } catch (Exception ex) { outputPort.Handle(new GetCategoriesResponse(null, null, false, ex.ToString())); return(false); } }
public IActionResult Index() { //var retorno = _dbContext.ShoppingLists.Where(x => x.Amount == 1).FirstOrDefault(); var retorno = _repository.List <ShoppingList>().Select(ShoppingListDTO.FromShoppingList).ToList(); return(View()); }
private static List <CommandWordEntity> GetMissingCommandWords(IRepository repository) { const string conventionSuffix = "Command"; // Access the assembly to make sure it's loaded Assembly assembly = typeof(BlastCommand).Assembly; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); IEnumerable <TypeInfo> allTypes = assemblies.SelectMany(x => x.DefinedTypes); var concreteCommands = allTypes .Where(x => typeof(IBotCommand).IsAssignableFrom(x)) .Where(x => !x.IsAbstract) .Where(x => !x.IsSubclassOf(typeof(DataEntity))) .Where(x => x.FullName.EndsWith(conventionSuffix)) .ToList(); var storedCommandWords = repository.List(CommandWordPolicy.OnlyPrimaries()).Select(x => x.CommandWord); List <CommandWordEntity> missingDefaults = concreteCommands .Select(commandType => new CommandWordEntity { CommandWord = commandType.Name.Substring(0, commandType.Name.Length - conventionSuffix.Length), FullTypeName = commandType.FullName, IsPrimary = true }) .Where(x => !storedCommandWords.Contains(x.CommandWord)) .ToList(); return(missingDefaults); }
public IActionResult List() { var items = _postRepository.List() .Select(item => PostShortDTO.ShortPost(item)); return(Ok(items)); }
public ActionResult Details(int?id) { Vozilo vozilo = voziloRepository.GetById(id); ViewBag.Servisi = servisRepository.List().Where(servis => servis.VoziloID == id).OrderByDescending(servis => servis.Datum); return(View(vozilo)); }
public IActionResult List() { var items = _todoRepository.List() .Select(item => _mapper.Map <ToDoItem, ToDoItemDTO>(item)); return(Ok(items)); }
public async Task <IActionResult> Login(LoginModel loginModel) { var user = _repository.List <User>().FirstOrDefault(u => u.PinNumber == loginModel.PinNumber); if (user == null) { ModelState.AddModelError("", "User not found"); return(View()); } var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString())); identity.AddClaim(new Claim(ClaimTypes.Name, user.PinNumber)); identity.AddClaim(new Claim(ClaimTypes.GivenName, user.UserName)); //foreach (var role in user.Roles) //{ // identity.AddClaim(new Claim(ClaimTypes.Role, role.Role)); //} var principal = new ClaimsPrincipal(identity); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); return(RedirectToAction("Index", "Home")); }
public IActionResult List() { var items = _repository.List <ToDoItem>() .Select(ToDoItemDTO.FromToDoItem); return(Ok(items)); }
public IActionResult GetList() { var customers = _repository.List <Customer>() .Select(c => c.ToDto()); return(Ok(customers)); }
public IActionResult Index() { var items = _repository.List <Viagem>() .Select(ViagemDTO.From); return(View(items)); }
public async Task <List <RSSFeedDTO> > List() { return(await _repository.List("Category") .OrderBy(a => a.Name) .Select(a => new RSSFeedDTO() { Id = a.Id, Name = a.Name, XMLFileAddress = a.XMLFileAddress, Category = new CategoryDTO() { Name = a.Category.Name, Id = a.Category.Id } }) .ToListAsync()); }
public frm_editar_caso_detalle_PL(IRepository <Encabezado, int> repository) { InitializeComponent(); #region Combo placa activo Obj_activos_BLL.listar_activos(ref Obj_activos_DAL); if (Obj_activos_DAL.smsjError == string.Empty) { cmb_placa_activo.DisplayMember = "Descripción"; cmb_placa_activo.ValueMember = "Código"; cmb_placa_activo.DataSource = Obj_activos_DAL.Ds.Tables[0]; } #endregion #region Combo caso //if (Obj_casoencabezado_DAL.smsjError == string.Empty) //{ // var mockObject = new Cls_casoencabezado_DAL {iId_Caso_Enc = -1 }; // cmb_id_caso_curso.DisplayMember = "Descripcion"; // cmb_id_caso_curso.ValueMember = "Id"; // cmb_id_caso_curso.DataSource = _encabezadoRepository.List(mockObject); //} cmb_id_caso_curso.DisplayMember = "Id"; cmb_id_caso_curso.ValueMember = "Id"; var mockObject = new Encabezado { Id = -1 }; cmb_id_caso_curso.DataSource = repository.List(mockObject); #endregion }
public void OnGet() { Ninjas = _ninjaRepository.List() .Select(n => new NinjaViewModel { Id = n.Id, Name = n.Name }).ToList(); }
public async Task <PropuestaDTO> Handle(UpdatePropuestaById request, CancellationToken cancellationToken) { var prop = _repository.GetById <Propuesta>(request.id); prop.ContratistaId = request.contratistaId; prop.Descripcion = request.descripcion; prop.RubroId = request.rubroId; prop.Nombre = request.nombre; prop.Descripcion = request.descripcion; prop.Monto = request.monto; prop.Updated = DateTime.UtcNow; prop.Status = (Helpers.PropuestasStatus)request.Status; _repository.Update(prop); prop = _repository.List <Propuesta>(t => t.Contratista, t => t.Usuario, t => t.Rubro).Find(a => a.Id == request.id); return(new PropuestaDTO { Id = prop.Id, Nombre = prop.Nombre, Descripcion = prop.Descripcion, NombreContratista = $"{prop.Contratista.Nombre} {prop.Contratista.Apellido}", NombreUsuario = $"{prop.Usuario.Nombre} {prop.Usuario.Apellido}", Monto = prop.Monto, Rubro = prop.Rubro.Nombre, Updated = prop.Updated, Created = prop.Created, Status = PropuestasStatusExtensions.ToFriendlyString(prop.Status), }); }
public void Handle(TeamRecordsChangedEvent domainEvent) { var teams = _repository.List(new TeamWithRecord()); var teamModels = _mapper.Map <List <Team>, TeamViewModel[]>(teams); _teamHub.Clients.All.TeamRecordsChanged(teamModels); }
public static IQueryable<Post> GetPublishedPosts(IRepository repository) { //TODO: Limitation in current version of the Norm driver. Need to pull everything return repository.List<Post>() .Where(x => x.IsPublished).ToList() .OrderByDescending(x => x.Created).AsQueryable(); }
public static IQueryable<Tag> GetTags(IRepository repository) { //TODO: Nasty. Need to deal with m-m relationships in some way.... var posts = repository.List<Post>().ToList(); var tags = new List<Tag>(); foreach(var post in posts) { tags = tags.Union(post.Tags).Distinct().ToList(); } return tags.AsQueryable(); }
public static BlogSettings Get(IRepository repo) { return repo.List<BlogSettings>().Single(); }
private static void GenerateRouteDirectionReals(Route route, IRepository rep) { Dictionary<string, Route> s_routes = null; if (s_routes == null) { var routes = rep.List<Route>(); s_routes = new Dictionary<string, Route>(); foreach (var i in routes) { s_routes[i.Name] = i; } } string realRoute = route.DirectionExpression; if (string.IsNullOrEmpty(route.DirectionExpression)) { route.DirectionReal = null; return; } string[] subRoute = route.DirectionExpression.Split(new char[] {'|', '(', ')' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < subRoute.Length; ++i) { string s = subRoute[i].Trim(); if (s_routes.ContainsKey(s)) { if (string.IsNullOrEmpty(s_routes[s].DirectionReal)) { GenerateRouteDirectionReals(s_routes[s], rep); } if (string.IsNullOrEmpty(s_routes[s].DirectionReal)) { throw new ArgumentException(string.Format("There is no route named of {0}", subRoute[i])); } realRoute = realRoute.Replace(subRoute[i], s_routes[subRoute[i]].DirectionReal); } } route.DirectionReal = realRoute; }