/// <summary> /// Добавить задачу /// </summary> /// <param name="model"></param> public void AddTask(TaskExtModel model) { Tasks.Add(model); /// Ленивая реализация - по-хорошему нужен отдельный event TasksUpdated?.Invoke(this, EventArgs.Empty); }
private void EditOkButton_Click(object sender, EventArgs e) { if (!ValidateFields()) { return; } string prevPath = Model.Photo; Model.Title = titleTextBox.Text; Model.Description = descriptionTextBox.Text; Model.Deadline = dateTimePicker.Value.Date; try { TaskProvider.Update(Model); if (picturePath.Text.Length != 0) { Model = TaskProvider.UploadImage(Model.Id, picturePath.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } TaskEdited?.Invoke(Model, EventArgs.Empty); this.Close(); }
private void CreateOkButton_Click(object sender, EventArgs e) { if (!ValidateFields()) { return; } TaskExtModel task = new TaskExtModel(); task.Title = titleTextBox.Text; task.Description = descriptionTextBox.Text; task.Begin = DateTime.Now; task.Deadline = dateTimePicker.Value.Date; try { task.Id = TaskProvider.CreateTask( task, SubjectId, GroupId); if (picturePath.Text != "") { TaskProvider.UploadImage(task.Id, picturePath.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } TaskCreated?.Invoke(task, EventArgs.Empty); this.Close(); }
/// <summary> /// Удалить модель /// </summary> /// <param name="model"></param> public void DeleteTask(TaskExtModel model) { Tasks.Remove(model); /// Ленивая реализация - по-хорошему нужен отдельный event TasksUpdated?.Invoke(this, EventArgs.Empty); TaskProvider.Delete(model.Id); }
public void SetModel(TaskExtModel model) { titleLabel.Text = model.Title; dateLabel.Text = model.Deadline.ToString("dd MM yyyy"); if (model.Photo == null) { showImageButton.Enabled = false; showImageButton.Visible = false; } }
public static void AddTest(TaskExtModel task, TestModel test) { string json = JsonConvert.SerializeObject(test); NameValueCollection param = new NameValueCollection(); param.Add("taskId", task.Id.ToString()); param.Add("test", json); var api = ApiProviderBase.GetInstance(); api.PostRequest <object>(UriResource.task_set_test, param); }
public TaskCreateForm(TaskExtModel model, int subjectId, int groupId) { InitializeComponent(); SubjectId = subjectId; GroupId = groupId; Model = model; titleTextBox.Text = Model.Title; dateTimePicker.Value = Model.Deadline; descriptionTextBox.Text = Model.Description; OkButton.Click += EditOkButton_Click; }
public static int CreateTask(TaskExtModel model, int subjectId, int groupId) { NameValueCollection param = new NameValueCollection(); param.Add("title", model.Title); param.Add("description", model.Description); param.Add("begin", model.Begin.ToString("yyyy-MM-dd")); param.Add("deadline", model.Deadline.ToString("yyyy-MM-dd")); param.Add("subjectId", subjectId.ToString()); param.Add("groupId", groupId.ToString()); var api = ApiProviderBase.GetInstance(); IApiResponse <int> response = api.PostRequest <int>(UriResource.task_create, param); return(response.data); }
public static void Update(TaskExtModel model) { NameValueCollection param = new NameValueCollection(); param.Add("taskId", model.Id.ToString()); param.Add("title", model.Title.ToString()); param.Add("description", model.Description.ToString()); param.Add("deadline", model.Deadline.ToString("yyyy-MM-dd")); if (model.Photo != null) { param.Add("photo", model.Photo.ToString()); } var api = ApiProviderBase.GetInstance(); api.PostRequest <object>(UriResource.task_update, param); }
/// <summary> /// Изменить задачу /// </summary> /// <param name="model"></param> public void EditTask(TaskExtModel model) { for (int i = 0; i < Tasks.Count; i++) { if (Tasks[i].Id == model.Id) { Tasks[i].Title = model.Title; Tasks[i].Description = model.Description; Tasks[i].Begin = model.Begin; Tasks[i].Deadline = model.Deadline; Tasks[i].Photo = model.Photo; Tasks[i].Test = model.Test; break; } } /// Ленивая реализация - по-хорошему нужен отдельный event TasksUpdated?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Удалить модель /// </summary> /// <param name="model"></param> public void DeleteTask(TaskExtModel model) { Model.DeleteTask(model); }
/// <summary> /// Обновить модель /// </summary> /// <param name="model"></param> public void EditTask(TaskExtModel model) { Model.EditTask(model); }
/// <summary> /// Добавить задачу /// </summary> /// <param name="model"></param> public void AddTask(TaskExtModel model) { Model.AddTask(model); }