private void SetPeriod() { var Services = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId)); GraphCanvasSettings.StartTime = (Services.Min(x => x.StartTime) / 60) * 60; GraphCanvasSettings.EndTime = (Services.Max(x => x.EndTime) / 60 + 1) * 60; }
private void AddShapeHelp(BindableCollection <ShapeData> Collection, object param, List <TextBoxDropDownModel> props, List <TextBoxDropDownModel> Letterprops) { DataAccess da = new DataAccess(); int maxId = 0; if (Collection.Count > 0) { maxId = Collection.Max(x => x.ShapeId); } var data = da.GetDataShape(maxId + 1, param.ToString()); var textProp = da.AddTextBoxProp(maxId + 1, param.ToString()); var textLetterProp = da.AddTextBoxProp(maxId + 1, "AB"); data = Formatting(data); if (data.IsRepeat == false) { Collection.Add(data); props.Add(textProp); Letterprops.Add(textLetterProp); } }
/// <summary> /// Adds new task to task list and saves to file /// </summary> /// <param name="contentNew">Content of new task</param> public void AddNewTask(string contentNew) { // check if empty if (string.IsNullOrWhiteSpace(ContentNew)) { // display error message MessageBox.Show("Please enter a name for the new task", "Error"); return; } // create new task object var newTask = new Task(ContentNew); // assign id to new task if (taskList.Count != 0) // list is not empty, current id = last id + 1 { newTask.Id = taskList.Max(x => x.Id) + 1; } else // if list is empty start with id = 1 { newTask.Id = 1; } // add to list taskList.Add(newTask); SaveToFile(); ContentNew = string.Empty; }
public void AddTodo(string txtAddBlock = null) { int MaxId = 1; if (_toDo.Count > 0) { MaxId = _toDo.Max(x => x.Id) + 1; } if (TxtTodo == null) { ToDo.Add(new ToDoModel { Id = MaxId, Name = "Task" + MaxId, Complete = false, Description = txtAddBlock, CreatedDate = GetDateNow, UpdatedDate = GetDateNow }); } else { TxtTodo.Description = txtAddBlock; TxtTodo.UpdatedDate = GetDateNow; ToDo.Refresh(); TxtTodo = null; ContentAddToDo = "Add"; } TxtAddBlock = ""; NotifyOfPropertyChange(() => TxtAddBlock); }
public static int GetId(BindableCollection <Car> collection) { if (collection.Count != 0) { id = collection.Max(x => x.Id); return(++id); } else { return(++id); } }
public bool AddUkod(UkodModel ukod) { bool success = true; try { BindableCollection <UkodModel> adatok = GetAllUkod(); int id = 0; try { id = adatok.Max(x => x.Id); } catch (Exception) { } ukod.Id = id + 1; adatok.Add(ukod); WriteXml(adatok); } catch (Exception e) { success = false; } return(success); }