// GET: Customer/Create public ActionResult Create() { var repo = new RecordsRepository(); var customer = repo.CreateRecord(); return(View(customer)); }
// GET: Record/Create public ActionResult Create() { var repo = new RecordsRepository(); var Record = repo.CreateRecord(); return(View(Record)); }
// GET: Customer public ActionResult Index() { var repo = new RecordsRepository(); var recordsList = repo.GetRecords(); return(View(recordsList)); }
public JsonResult Index(string query) { RecordsRepository repo = new RecordsRepository(); var records = repo.GetAllRecords(); var result = new List <Info>(); Stopwatch stop = new Stopwatch(); stop.Start(); foreach (var record in records) { var str = record.Name + " " + record.Abbr; int[] diff = Search.DoSearch(query, str); result.Add(new Info() { Dif = diff, Value = str }); } result.Sort(); stop.Stop(); var output = new List <string>(); for (int i = 0; i < 10; i++) { output.Add(result[i].Value + " " + result[i].Dif[0] + " " + result[i].Dif[1]); } output.Add(String.Format("Время поиска {0}", stop.ElapsedMilliseconds)); return(Json(output, JsonRequestBehavior.AllowGet)); }
public void GetAllTest() { IRecordsRepository repo = new RecordsRepository(); Assert.Empty(repo.GetAll()); repo.AddRecord(new Person() { LastName = "L", FirstName = "F", FavoriteColor = "Blue", Gender = "Male", DateOfBirth = DateTime.Now }); Assert.Single(repo.GetAll()); }
static void Main(string[] args) { using (RecordsRepository repository = new RecordsRepository()) { foreach (var rec in repository.GetAll()) { ShowRecordInfo(rec); } Console.WriteLine(new String('=', 70)); List <Record> records = repository.GetAll().ToList(); Record recordToUpdate = records[0]; recordToUpdate.Author = "Vasya"; repository.Update(recordToUpdate); foreach (var rec in repository.GetAll()) { ShowRecordInfo(rec); } Console.WriteLine(new String('=', 70)); repository.Delete(6); foreach (var rec in repository.GetAll()) { ShowRecordInfo(rec); } Console.WriteLine(new String('=', 70)); repository.Add(new Record("Hello GlobalLogic", "Sweet kitty")); foreach (var rec in repository.GetAll()) { ShowRecordInfo(rec); } Console.WriteLine(new String('=', 70)); } }
public ActionResult Create([Bind(Include = "RecordId, RecordValue, SelectedExpenseTypeId, SelectedSubcategoryId, SelectedCategoryCode, SelectedPeriodCode")] RecordEditViewModel model) { try { if (ModelState.IsValid) { var repo = new RecordsRepository(); bool saved = repo.SaveRecord(model); if (saved) { return(RedirectToAction("Index")); } } // Handling model state errors is beyond the scope of the demo, so just throwing an ApplicationException when the ModelState is invalid // and rethrowing it in the catch block. throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { throw ex; } }
private static void InitDb(string dbPath) { bool exists = File.Exists(dbPath); if (exists) { File.Delete(dbPath); } var stackRepo = new StacksRepository(dbPath); var stacks = new List <Stack> { new Stack { Type = StackType.Day, StartDate = DateTime.Today }, new Stack { Type = StackType.None, StartDate = DateTime.Today }, new Stack { Type = StackType.Week, StartDate = DateTime.Today }, new Stack { Type = StackType.Month, StartDate = DateTime.Today }, }; foreach (var record in stacks) { stackRepo.AddAsync(record); } var rRepo = new RecordsRepository(dbPath); var records = new List <Record>() { new Record { IsFinished = true, Name = "Meeting at Akadem", Description = "Meeting starts at 10:00 on the building", StackId = stacks[0].Id }, new Record { Name = "Buy bread at the shop", Description = "Go to the Silpo after work and buy some bread", StackId = stacks[0].Id }, new Record { Name = "Visit a doctor", Description = "Some description here", Status = Status.Active, StackId = stacks[0].Id }, new Record { Name = "Bring my laptop to the work", Description = "Some description here", Status = Status.Deleted, StackId = stacks[0].Id }, new Record { Name = "Create a report", Description = "Some description here", Status = Status.Modified, StackId = stacks[0].Id }, new Record { Name = "Fix all bugs", Description = "Some description here", Status = Status.Active, StackId = stacks[0].Id }, new Record { Name = "Meeting at Akadem", Description = "Meeting starts at 10:00 on the building", StackId = stacks[0].Id }, new Record { Name = "Buy bread at the shop", Description = "Go to the Silpo after work and buy some bread", StackId = stacks[0].Id }, new Record { Name = "Visit a doctor", Description = "Some description here", Status = Status.Active, StackId = stacks[0].Id }, new Record { Name = "Bring my laptop to the work", Description = "Some description here", Status = Status.Deleted, StackId = stacks[0].Id }, new Record { Name = "Create a report", Description = "Some description here", Status = Status.Modified, StackId = stacks[0].Id }, new Record { Name = "Fix all bugs", Description = "Some description here", Status = Status.Active, StackId = stacks[0].Id }, }; foreach (var record in records) { rRepo.AddAsync(record); } }
static void Main(string[] args) { using (Context context = new Context()) { _recordsRepository = new RecordsRepository(context); while (true) { // Get a Command to Execute string userInput = PromptUser(PromptType.Command); while (!CJCommandValidator.IsValidCommand(userInput)) { userInput = PromptUser(PromptType.InvalidCommand); } char command = char.ToUpper(userInput[0]); // Execute that command switch (command) { // Add Records from a file to the repository case 'R': userInput = PromptUser(PromptType.File); string path = AppDomain.CurrentDomain.BaseDirectory + userInput; IList <Record> recordsToAddToDB = null; try { using (StreamReader file = new StreamReader(path)) { recordsToAddToDB = CJFileParser.ParseFile(file); } } catch (IOException e) { CJPrintHelper.PrintErrorMessage("Could not load the file."); } if (recordsToAddToDB == null) { CJPrintHelper.PrintErrorMessage("There are no valid records to be added."); } else { _recordsRepository.AddList(recordsToAddToDB); CJPrintHelper.PrintSuccessMessage("Records created successfully!"); } break; // Print Records ordered by gender case 'G': IList <Record> printMe = _recordsRepository.GetSortedRecords(RecordsRepository.SortMethod.Gender); CJPrintHelper.PrintSortedRecords(RecordsRepository.SortMethod.Gender, printMe); break; // Print Records ordered by DOB case 'B': printMe = _recordsRepository.GetSortedRecords(RecordsRepository.SortMethod.DateOfBirth); CJPrintHelper.PrintSortedRecords(RecordsRepository.SortMethod.DateOfBirth, printMe); break; // Print Records ordered by last name case 'L': printMe = _recordsRepository.GetSortedRecords(RecordsRepository.SortMethod.LastName); CJPrintHelper.PrintSortedRecords(RecordsRepository.SortMethod.LastName, printMe); break; // Escapes the program case 'X': Console.WriteLine("Thanks for stopping by...."); return; default: break; } } } }
public IActionResult GetAllByMonth() { return(new ObjectResult(RecordsRepository.GetCrimesByMonth())); // objectResult converts the generic to an ienumerable }
public RecordsController() { this.db = new RecordsRepository(); }