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;
        }
Example #4
0
        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));
        }
Example #5
0
        //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());
        }
Example #6
0
        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;
        }
Example #7
0
        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;
        }
Example #8
0
        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));
        }
Example #9
0
        public RecordsPage()
        {
            recordsViewModel = new RecordsViewModel();
            InitializeComponent();

            game              = BaseViewModel.propertiesDict_getGame();
            defaultGame       = game;
            mode              = BaseViewModel.propertiesDict_getMode();
            defaultMode       = mode;
            recentRecordsType = EFilter_RRType.map;
        }
Example #10
0
        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));
        }
Example #12
0
        /// <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));
        }
Example #13
0
        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);
            }
        }
Example #14
0
        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();
            }
        }
Example #18
0
        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();
        }
Example #20
0
        //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));
        }
Example #24
0
 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);
        }
Example #26
0
        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);
        }
Example #27
0
 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);
        }
Example #29
0
 public Records()
 {
     RecordsViewModel = new RecordsViewModel(new PageService());
     InitializeComponent();
     RecordsViewModel.DisplayListOfRecordsCommand.Execute(null);
 }
Example #30
0
        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);
        }
Example #31
0
 public RecordsPage()
 {
     InitializeComponent();
     DataContext = new RecordsViewModel();
 }
Example #32
0
 public RecordsPage()
 {
     InitializeComponent();
     BindingContext = new RecordsViewModel(this);
 }
Example #33
0
 public ReportViewModel(DateViewModel today, DateViewModel report, RecordsViewModel records)
 {
     TodayDate = today;
     ReportDate = report;
     RecordsViewModel = records;
 }