Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
using System;
using System.Collections.Generic;
using MyDailyTaskManger.Models;
using Xamarin.Forms;
using Newtonsoft.Json;
using System.IO;
namespace MyDailyTaskManger
{
public partial class AddTaskPage : ContentPage
{
private String FileName;
public AddTaskPage()
{
InitializeComponent();
FileName = null;
}
public async void HandleForm(object sender, EventArgs eventArgs)
{
var task = new Task();
task.title = this.title.Text;
task.detail = this.details.Text;
task.dateCreated = DateTime.Now.ToString();
if (null != this.FileName)
{
string FullFileName = Path.Combine(App.FolderPath, this.FileName);
task.fileName = FullFileName;
string json = JsonConvert.SerializeObject(task);
File.WriteAllText(FullFileName, json);
bool ok = await DisplayAlert(
"Success",
$"{this.FileName} File updated",
"Done",
"Contine update"
);
if (ok == true)
{
ViewTaskPage page = new ViewTaskPage(task);
// page.BindingContext = task;
await Navigation.PushAsync(page);
}
} else
{
this.FileName = $"{Path.GetRandomFileName()}.task.txt";
string FullFileName = Path.Combine(App.FolderPath, this.FileName);
task.fileName = FullFileName;
string json = JsonConvert.SerializeObject(task);
File.WriteAllText(FullFileName, json);
bool ok = await DisplayAlert(
"Success",
$"{this.FileName} File Created",
"Done",
"Contine update"
);
if (ok == true)
{
ViewTaskPage page = new ViewTaskPage(task);
// page.BindingContext = task;
await Navigation.PushAsync(page);
}
}
}
}
}