public static String ViewFreeTablesHall(String hallId, String date, String time) { #region Находим список забранированных столов на необходимый день ReservedTablesMapper reservedTablesMapper = new ReservedTablesMapper(); DayMapper dayMapper = new DayMapper(); List <int> busyTables = new List <int>(); date = date.Substring(6, 4) + "-" + date.Substring(3, 2) + "-" + date.Substring(0, 2); int idDay = dayMapper.GetDayId(date); // id даты бронирования busyTables.AddRange(reservedTablesMapper.GetBusyTables(idDay.ToString())); #endregion #region Список всех столов в зале HallMapper hallMapper = new HallMapper(); List <int> tablesInHall = new List <int>(); tablesInHall.AddRange(hallMapper.GetTablesInHall(hallId)); #endregion #region Свободные столы в зале foreach (var table in busyTables) { tablesInHall.Remove(table); } #endregion String cookieString = tablesInHall.Aggregate("", (current, table) => current + (table + " ")); cookieString = cookieString.Substring(0, cookieString.Length - 1); return(cookieString); }
public void CreateTask(TaskValidation taskValidation, DayRepository dayRepository, ToDoTaskRepository taskRepository, DayMapper dayMapper, TextBox textBoxName, TextBox textBoxDate, RichTextBox richTextBoxDescription, int statusValue, int priorityValue) { bool isCorrect = taskValidation.isInputOk(textBoxName.Text, richTextBoxDescription.Text, textBoxDate.Text); if (isCorrect) { using (var dbContex = new ToDoAppDbContext()) { dayRepository = new DayRepository(dbContex); taskRepository = new ToDoTaskRepository(dbContex); var myDay = dayRepository.GetByDate(DateTime.Parse(textBoxDate.Text)); if (myDay == null) { dayMapper = new DayMapper(); var tempDay = new DayModel(); tempDay.Date = DateTime.Parse(textBoxDate.Text); dayRepository.Update(dayMapper.Map(tempDay)); } myDay = dayRepository.GetByDate(DateTime.Parse(textBoxDate.Text)); taskRepository.Update(new Database.Entities.TaskToDo { Name = textBoxName.Text, Description = richTextBoxDescription.Text, DayId = myDay.DayId, Status = statusValue, Priority = priorityValue }); } MessageBox.Show("The database was successfully modified"); } }
public static String InsertInformationOrder(String name, String phone, String table, String time, String date) { DayMapper dayMapper = new DayMapper(); date = date.Substring(6, 4) + "-" + date.Substring(3, 2) + "-" + date.Substring(0, 2); int idDay = dayMapper.GetDayId(date); // id даты бронирования ReservedTablesMapper reservedTablesMapper = new ReservedTablesMapper(); //time = time.Replace(':', '.'); String idOrder = reservedTablesMapper.ReserveTable(name, phone, table, time, idDay); return(idOrder); }
public void ModelToEntity_DayToModelDay_ReturnsTrue() { //Arrange var day = new DayModel(); day.Id = 1; day.Day1 = DayEnum.Monday; //Act var result = DayMapper.ModelToEntity(day); //Assert Assert.AreEqual(day.Id, result.Id); }
public Form1() { InitializeComponent(); BindMyButtonsToEvent(); dayMapper = new DayMapper(); toDoTaskMapper = new ToDoTaskMapper(); taskMapper = new ToDoTaskMapper(); deleteItem = new DeleteItem(); using (var dbContex = new ToDoAppDbContext()) { dbContex.Database.EnsureCreated(); } LoadDataToMyComboBox(); //SetUpMyListBox(); mainTimer.Start(); }
private Result <object> SaveLogBook(LogBook logBook) { try { if (!Directory.GetParent(fileName).Exists) { Directory.GetParent(fileName).Create(); } var data = new LogBookData { // save only for 2 latest months Days = logBook.Days.OrderByDescending(l => l.DayStarted) .Take(61).Select(d => DayMapper.Map(d)).ToList(), Stash = logBook.Stash }; string json = JsonConvert.SerializeObject(data); File.WriteAllText(fileName, json); return(Results.SuccessfulUnit); } catch (Exception e) { return(Results.Failure <object>($"Failed to save sheets: {e.Message}")); } }