public async Task CreateRecord(RecordsViewModel record) { var entity = _mapper.Map <RecordsViewModel, Record>(record); await _recordRepository.Create(entity); await _recordRepository.Save(); }
public async Task UpdateRecord(RecordsViewModel record) { var newRecord = _mapper.Map <RecordsViewModel, Record>(record); _recordRepository.Update(newRecord); await _recordRepository.Save(); }
public RecordsTopCountriesPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; InitializeComponent(); Title = title; }
public async Task <IActionResult> Index(int page = 1, string search = "", int Year = 0) { int pageSize = 11; var applicationDbContext = new List <Record>(); if (String.IsNullOrEmpty(search)) { if (Year == 0) { applicationDbContext = await _context.Records.Include(r => r.Supplier).ToListAsync(); } else { applicationDbContext = await _context.Records.Where(n => n.Date.Year == Year).ToListAsync(); } } else // jak jest parametr do wyszukiwania { foreach (var item in _context.Records) { if (item.Number.Contains(search)) { applicationDbContext.Add(item); } } if (applicationDbContext.Count == 0) { } } var recordsViewModel = new RecordsViewModel(); recordsViewModel.Records = applicationDbContext; recordsViewModel.Suppliers = await(from supplier in _context.Suppliers select supplier).ToListAsync(); recordsViewModel.Records = (applicationDbContext .OrderBy(p => p.RecordId) .Skip((page - 1) * pageSize) .Take(pageSize)).ToList(); recordsViewModel.PaginationViewModel = new PaginationViewModel { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = applicationDbContext.Count() }; recordsViewModel.Search = search; return(View(recordsViewModel)); }
//Get Records/PersonalRecords public ActionResult PersonalRecords() { var idusuario = User.Identity.GetUserId(); RecordsViewModel[][] records = new RecordsViewModel[2][]; records[0] = get_records.sacarRecordsPersonales(idusuario, "1"); records[1] = get_records.sacarRecordsPersonales(idusuario, "2"); ViewData["Records"] = records; return(View()); }
public RecordsCountryTopPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; InitializeComponent(); Title = title; CountryPicker.ItemsSource = EFilter_ToString.ctopCountries; }
public RecordsOldestPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; this.oldestType = EFilter_ORType.map; InitializeComponent(); Title = title; }
public async Task <IActionResult> ReportsToPrint(int Year = 0) { var recordViewList = new RecordsViewModel(); recordViewList.Records = await(_context.Records.Where(n => n.Date.Year == Year).ToListAsync()); recordViewList.Suppliers = await(from supplier in _context.Suppliers select supplier).ToListAsync(); recordViewList.Year = Year; return(View(recordViewList)); }
public RecordsPage() { recordsViewModel = new RecordsViewModel(); InitializeComponent(); game = BaseViewModel.propertiesDict_getGame(); defaultGame = game; mode = BaseViewModel.propertiesDict_getMode(); defaultMode = mode; recentRecordsType = EFilter_RRType.map; }
public RecordsMostPage(string title, RecordsViewModel recordsViewModel, EFilter_Game game, EFilter_Mode mode) { this.recordsViewModel = recordsViewModel; this.game = game; this.mode = mode; mostType = EFilter_MostType.wr; mostTypeString = "Current WRs"; InitializeComponent(); Title = title; MostTypePicker.ItemsSource = EFilter_ToString.mosttype_arr; }
public async Task <IActionResult> Records() { var user = await GetCurrentUserAsync(); var token = await _appsContainer.AccessToken(); var records = await _recordsService.ViewMyRecordsAsync(token, user.Id); var model = new RecordsViewModel(user, records.Records); return(View(model)); }
/// <summary> /// Загрузка страницы с записями. Отображается сразу после входа в тему. /// </summary> /// <param name="subjectId">Идентификатор темы.</param> /// <param name="subjectName">Тема.</param> /// <returns>Страница записей.</returns> public async Task <IActionResult> Index(int subjectId, string subjectName) { LogInformation("Загрузка страницы записей."); string[] days = await GetDays(subjectId); var viewModel = new RecordsViewModel { SubjectName = subjectName, Records = await GetRecordsPerDay(subjectId, DateTime.ParseExact(days.First(), _dayFormat, null).Date), Days = days.Select(d => new SelectListItem(d, d)).ToList(), CurrentDay = days.First(), RecordTypes = GetRecordTypes() }; LogInformation("Все данные для страницы записей успешно получены."); return(View("Index", viewModel)); }
public async Task CreateComments([FromBody] RecordsViewModel magazine) { if (ModelState.IsValid) { try { foreach (var record in magazine.records) { var exist = commentRepository.Get(r => r.MagazineId == magazine.MagazineId && r.StudentId == record.studentId).FirstOrDefault(); Comment newComment = new Comment() { MagazineId = magazine.MagazineId, StudentId = record.studentId, Note = record.Note, }; if (exist != null) { exist.Note = newComment.Note; await commentRepository.Update(exist); } else { await commentRepository.Insert(newComment); } } var answer = new { success = String.Format("Примечание успешно создано!") }; Response.StatusCode = StatusCodes.Status200OK; await Response.WriteAsync(ConvertToJson(answer)); } catch (Exception e) { ModelState.AddModelError("error", e.Message); await Response.BadRequestHelper(ModelState.Values); } } else { await Response.BadRequestHelper(ModelState.Values); } }
public async Task CreateRecords([FromBody] RecordsViewModel magazine) { if (ModelState.IsValid) { try { var date = DateTime.Parse(magazine.records.First().Date); var exist = recordsRepository.Get(r => r.MagazineId == magazine.MagazineId && r.Date == date).FirstOrDefault(); if (exist != null) { throw new Exception(String.Format("Для даты {0} уже существуют записи!", date.ToShortDateString())); } foreach (var record in magazine.records) { Record newRecord = new Record() { Date = DateTime.Parse(record.Date), MagazineId = magazine.MagazineId, StudentId = record.studentId, Visit = record.Note }; await recordsRepository.Insert(newRecord); } var answer = new { success = String.Format("Запись успешно создана!") }; Response.StatusCode = StatusCodes.Status200OK; await Response.WriteAsync(ConvertToJson(answer)); } catch (Exception e) { ModelState.AddModelError("error", e.Message); await Response.BadRequestHelper(ModelState.Values); } } else { await Response.BadRequestHelper(ModelState.Values); } }
private async void TxtRecord_EditRecord_SelectionChanged(object sender, SelectionChangedEventArgs e) { string Message = string.Empty; RecordsViewModel recordsViewModel = new RecordsViewModel(); recordsViewModel.SearchSpecificCustomerRecords(ref editRecord, ref Message); if (Message != string.Empty) { var newRecordResultDialog = new NewRecordResultDialog(Message, ""); await newRecordResultDialog.ShowAsync(); } else { editRecord.IsEditRecordBtnEnabled = true; } }
public async Task <ActionResult> Edit(RecordsViewModel record) { RecordViewModelValidator validations = new RecordViewModelValidator(); ValidationResult result = await validations.ValidateAsync(record); if (result.IsValid) { await _recordServices.UpdateRecord(record); return(RedirectToAction("Index")); } else { foreach (var failure in result.Errors) { ModelState.AddModelError(failure.PropertyName, failure.ErrorMessage); } } return(View(record)); }
private async void ASBAllRecords_EditRecord_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { string Message = string.Empty; RecordsViewModel recordsViewModel = new RecordsViewModel(); recordsViewModel.SearchAllCustomerRecords(ref editRecord, ref Message); if (Message != string.Empty) { var newRecordResultDialog = new NewRecordResultDialog(Message, ""); await newRecordResultDialog.ShowAsync(); } else if (editRecord.RecordsList.Count == 0 || editRecord.RecordsList is null) { Message = "No se encontró ningún expediente con el criterio dado"; var newRecordResultDialog = new NewRecordResultDialog(Message, ""); await newRecordResultDialog.ShowAsync(); } }
public RecordsViewModelTests() { SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext()); this.testScheduler = new TestScheduler(); this.testMessenger = new TestMessenger(); Messenger.OverrideDefault(this.testMessenger); this.logSource = new Mock <ILogSource>(MockBehavior.Strict); this.logSource .SetupGet(x => x.Status) .Returns(this.status.ObserveOn(this.testScheduler)); this.viewModel = new RecordsViewModel { LogSourceInfo = new LogSourceInfo(this.logSource.Object, null, false, false), Scheduler = this.testScheduler }; this.viewModel.Initialize(); }
public RecordsViewModelTests() { SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext()); this.testScheduler = new TestScheduler(); this.testMessenger = new TestMessenger(); Messenger.OverrideDefault(this.testMessenger); this.logSource = new Mock<ILogSource>(MockBehavior.Strict); this.logSource .SetupGet(x => x.Status) .Returns(this.status.ObserveOn(this.testScheduler)); this.viewModel = new RecordsViewModel { LogSourceInfo = new LogSourceInfo(this.logSource.Object, null, false, false), Scheduler = this.testScheduler }; this.viewModel.Initialize(); }
//Coger los records de un juego de un usuario en concreto public static RecordsViewModel[] sacarRecordsPersonales(string idUsuario, string idJuego) { try { int contador = 0; var conectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-proyecto_final_moha_nestor-20180515073549.mdf;Initial Catalog=aspnet-proyecto_final_moha_nestor-20180515073549;Integrated Security=True"; System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(conectionString); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = $"SELECT UserName, RecordTimeStamp, Points FROM Records, AspNetUsers WHERE IdGame = @idgame AND IdUser = Id AND IdUser = @idusuario ORDER BY Points DESC"; cmd.Parameters.AddWithValue("@idgame", idJuego); cmd.Parameters.AddWithValue("@idusuario", idUsuario); cmd.Connection = sqlConnection1; sqlConnection1.Open(); cmd.ExecuteNonQuery(); SqlDataReader rdr = cmd.ExecuteReader(); RecordsViewModel puntuaciones; RecordsViewModel[] puntuacionesTotales = new RecordsViewModel[5]; while (rdr.Read() && contador < 5) { puntuaciones = new RecordsViewModel(); puntuaciones.Username = (string)rdr["UserName"]; puntuaciones.time = (string)rdr["RecordTimeStamp"]; puntuaciones.score = (int.Parse(rdr["Points"].ToString())); puntuacionesTotales[contador] = puntuaciones; contador++; } sqlConnection1.Close(); return(puntuacionesTotales); } catch { return(null); } }
private async void BtnAddRecord_Click(object sender, RoutedEventArgs e) { string Message = string.Empty; string recordNumber = string.Empty; RecordsViewModel recordsViewModel = new RecordsViewModel(); recordsViewModel.CreateNewCustomerRecord(ref Message, ref newRecord); if (Message == string.Empty) { Message = "El expediente se ha creado de manera exitosa"; recordNumber = "Número de expediente: " + newRecord.RecordId; var newRecordResultDialog = new NewRecordResultDialog(Message, recordNumber); await newRecordResultDialog.ShowAsync(); var recordsDialog = new RecordsDialog(); await recordsDialog.ShowAsync(); if (recordsDialog.BResult == 1) { checkRecord.CustomerSearchCriteria = newRecord.CustomerIdNumber; Pivot_Records.SelectedItem = PI_CheckRecords; ASBAllRecords.Focus(FocusState.Programmatic); } else { this.Frame.Navigate(typeof(HomePage), null, new DrillInNavigationTransitionInfo()); } } else { var newRecordResultDialog = new NewRecordResultDialog(Message, recordNumber); await newRecordResultDialog.ShowAsync(); } }
private async void BtnEditRecord_Click(object sender, RoutedEventArgs e) { string Message = string.Empty; RecordsViewModel recordsViewModel = new RecordsViewModel(); recordsViewModel.EditCustomerRecord(ref Message, ref editRecord); if (Message != string.Empty) { var newRecordResultDialog = new NewRecordResultDialog(Message, ""); await newRecordResultDialog.ShowAsync(); } else { Message = "El expediente se modificó de manera exitosa"; var newRecordResultDialog = new NewRecordResultDialog(Message, ""); await newRecordResultDialog.ShowAsync(); Frame.Navigate(typeof(HomePage), null, new DrillInNavigationTransitionInfo()); } }
// GET: Records public ActionResult Index() { Entity db = new Entity(); var records = Repository.GetRecordsReverse(db); List <RecordsViewModel> rvm = new List <RecordsViewModel>(); foreach (var item in records) { RecordsViewModel rec = new RecordsViewModel(); rec.Id = item.Id; rec.LocatId = item.LocatId; rec.UserId = item.UserId; rec.Total = item.Total; rec.DateT = item.DateT; rec.AmountP = item.AmountP; rec.PizzaType = item.PizzaType; rec.Size = item.Size; rec.Crust = item.Crust; rvm.Add(rec); } return(View(rvm)); }
public void Setup() { _pageService = new Mock <IPageService>(); _recordsViewModel = new RecordsViewModel(_pageService.Object); }
public async Task <string> CreateJsonId(RecordsViewModel record) { string jsonResult = await Task.Run(() => JsonConvert.SerializeObject(record)); return(jsonResult); }
public async Task <RecordsViewModel <FlightReservationModel> > RecordViewModel([FromBody] RecordsViewModel <FlightReservationModel> filterViewModel) { int?clubId = filterViewModel.FilterViewModel.ClubFilterApplied; int ActualPage = filterViewModel.PaginationInfo.ActualPage; switch (filterViewModel.PaginationInfo.PageCommand) { case PageCommand.MoveNext: ActualPage = filterViewModel.PaginationInfo.ActualPage + 1; break; case PageCommand.MovePrevious: ActualPage = filterViewModel.PaginationInfo.ActualPage - 1; break; } var reservations = await _recordViewModelService.GetRecord(ActualPage, 10, filterViewModel.FilterViewModel.AirplaneFilterApplied, filterViewModel.FilterViewModel.PilotFilterApplied); return(reservations); }
private void Records_clicked(object sender, RoutedEventArgs e) { DataContext = new RecordsViewModel(); ChangingContent.Content = new RecordsViewModel(); }
public async Task <RecordsViewModel <FlightReservationModel> > GetRecord(int pageIndex, int itemsPage, int?airplaneId, int?pilotId) { _logger.LogInformation("GetFlightRecord called"); string idNumber = "", tailNumber = ""; if (pilotId != null) { Pilot pilot = await _clubService.GetPilotById((int)pilotId); if (pilot != null) { idNumber = pilot.IdNumber; } } if (airplaneId != null) { Aircraft ar = await _aircraftRepository.GetByIdAsync((int)airplaneId); if (ar != null) { tailNumber = ar.TailNumber; } } ReservationSpecification flightPagingSpec = new ReservationSpecification(itemsPage * pageIndex, itemsPage, tailNumber, idNumber); ReservationSpecification flightSpec = new ReservationSpecification(tailNumber, idNumber); var flightOnPage = await _reservationRepository.ListAsync(flightPagingSpec); var totalFlight = await _reservationRepository.CountAsync(flightSpec); var airplanes = await GetAirplans(1); airplanes.Add(new AirplaneSelectModel() { Id = 0, TailNumber = "Select All" }); var vm = new RecordsViewModel <FlightReservationModel>() { Records = flightOnPage.Select(i => new FlightReservationModel() { Id = i.Id, DateFrom = i.DateFrom, DateTo = i.DateTo, IdNumber = i.IdNumber, TailNumber = i.TailNumber, UserInfo = i.ReservationInfo }), FilterViewModel = new FilterModel() { AirplaneSelects = airplanes, ClubSelects = await GetClubs(1), PilotSelects = await GetPilots(1), PilotFilterApplied = pilotId, ClubFilterApplied = 1, AirplaneFilterApplied = airplaneId, }, PaginationInfo = new PaginationInfoModel() { ActualPage = pageIndex, ItemsPerPage = flightOnPage.Count, TotalItems = totalFlight, TotalPages = int.Parse(Math.Ceiling((decimal)totalFlight / itemsPage).ToString()) } }; vm.PaginationInfo.Next = (vm.PaginationInfo.ActualPage >= vm.PaginationInfo.TotalPages - 1) ? "disabled" : ""; vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "disabled" : ""; return(vm); }
public Records() { RecordsViewModel = new RecordsViewModel(new PageService()); InitializeComponent(); RecordsViewModel.DisplayListOfRecordsCommand.Execute(null); }
public ReportViewModel ConvertToViewModel(IEnumerable<Record> records, double sum, DateTime date) { var todayDate = new DateViewModel { FullDate = DateTime.Now.GetDateTimeFormats()[0], ShortDate = DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + DateTime.Now.Year }; var reportDate = new DateViewModel { FullDate = date.GetDateTimeFormats()[0], ShortDate = date.Month + "/" + date.Day + "/" + date.Year }; var recordsViewModel = new RecordsViewModel { Records = records.Select(ConvertToViewModel), Sum = sum }; return new ReportViewModel(todayDate, reportDate, recordsViewModel); }
public RecordsPage() { InitializeComponent(); DataContext = new RecordsViewModel(); }
public RecordsPage() { InitializeComponent(); BindingContext = new RecordsViewModel(this); }
public ReportViewModel(DateViewModel today, DateViewModel report, RecordsViewModel records) { TodayDate = today; ReportDate = report; RecordsViewModel = records; }