Beispiel #1
0
        private Dictionary <string, List <string> > CompareVersions(TODOList oldVersion, TODOList newVersion)
        {
            var emailsToTasks = new Dictionary <string, List <string> >();

            if (newVersion.Items == null)
            {
                return(emailsToTasks);
            }

            foreach (var task in newVersion.Items)
            {
                if (string.IsNullOrWhiteSpace(task.AssignedEmail) || task.Complete || string.IsNullOrWhiteSpace(task.Description))
                {
                    continue;
                }

                if (oldVersion?.Items?.FirstOrDefault(x => string.Equals(x.Description, task.Description)) == null)
                {
                    List <string> tasks = null;
                    if (!emailsToTasks.TryGetValue(task.AssignedEmail, out tasks))
                    {
                        tasks = new List <string>();
                        emailsToTasks[task.AssignedEmail] = tasks;
                    }

                    tasks.Add(task.Description);
                }
            }


            return(emailsToTasks);
        }
Beispiel #2
0
 public static TODOListElement EditElementOfList(NewEditInputModel input, TODOList tempList)
 {
     TODOListElement tempListElement = tempList.getElement(input.myID);
     tempListElement.Details = input.Details;
     tempListElement.Title = input.Title;
     return tempListElement;
 }
        public async Task <IActionResult> OnPost(string listId, string tasks)
        {
            this.TODOList = await this.DataAccess.GetTODOListAsync(this.User.Identity.Name, listId);

            this.TODOList.Items = Newtonsoft.Json.JsonConvert.DeserializeObject <List <TODOListItem> >(tasks);
            await this.DataAccess.SaveTODOListAsync(this.TODOList);

            return(RedirectToPage("MyLists"));
        }
Beispiel #4
0
        public static string FormattedCompleteCount(TODOList list)
        {
            if (list.Items == null)
            {
                return("0/0");
            }

            return(list.Items.Where(x => x.Complete).Count() + "/" + list.Items.Count);
        }
Beispiel #5
0
 static public TODOList OpenList()
 {
     if (list == null)
     {
         Console.Write("\r\nFile name: ");
         list = TODOList.Open(Console.ReadLine());
         return(list);
     }
     return(list);
 }
Beispiel #6
0
    public static TODOList Open(string path)
    {
        if (!File.Exists(path))
        {
            throw new Exception("File doesn\'t exist");
        }
        TODOList list = new TODOList(path);

        list.Read();
        return(list);
    }
Beispiel #7
0
 static public TODOEntity EntityById(TODOList list)
 {
     Console.Write("ID: ");
     int.TryParse(Console.ReadLine(), out int id);
     if (id == 0)
     {
         throw new Exception("ID must a number");
     }
     Console.WriteLine();
     return(list.ReadById(id));
 }
Beispiel #8
0
        public async Task <IActionResult> OnPost()
        {
            var list = new TODOList
            {
                User = this.User.Identity.Name,
                Name = this.Name
            };

            await this.DataAccess.SaveTODOListAsync(list);

            return(RedirectToPage("EditList", new { Id = list.ListId }));
        }
Beispiel #9
0
        public async Task SaveTODOListAsync(TODOList list)
        {
            try
            {
                if (string.IsNullOrEmpty(list.ListId))
                {
                    list.ListId = Guid.NewGuid().ToString();
                }

                if (list.CreateDate == DateTime.MinValue)
                {
                    list.CreateDate = DateTime.UtcNow;
                }

                list.UpdateDate = DateTime.UtcNow;

                await this.Context.SaveAsync(list);
            }
            catch (Exception e)
            {
                throw new TODOListDataAccessException("Error saving TODO list", e);
            }
        }
 public async Task OnGet(string id)
 {
     this.TODOList = await this.DataAccess.GetTODOListAsync(this.User.Identity.Name, id);
 }
Beispiel #11
0
 public static void SetIsDoneOnElement(NewDeleteItemInputModel input, TODOList tempList)
 {
     TODOListElement tempListElement = tempList.getElement(input.ID);
     tempListElement.IsDone = true;
     tempList.setElement(input.ID, tempListElement);
 }
Beispiel #12
0
        static void Main(string[] args)
        {
            Menu menu = new Menu(() => {
                if (list != null)
                {
                    Console.WriteLine("=> Working with file: " + list.Path + "\r\n");
                }
                return("\r\n");
            });

            menu.Add("create", "Create new todo file", () => {
                Console.WriteLine("Name:");
                list = TODOList.Create(Console.ReadLine());
                return("\r\nTODO File created\r\n");
            });
            menu.Add("add", "Create new todo in list", () => {
                OpenList().Add(NewEntityDialog());
                OpenList().Save();
                return("\r\nTask successfully saved\r\n");
            });
            menu.Add("show", "Print todo with id", () => {
                try {
                    Console.WriteLine(EntityById(OpenList()).ToString());
                    return("\r\nTask successfully printed\r\n");
                }
                catch (Exception e) {
                    Console.WriteLine(e);
                    return("\r\nFail");
                }
            });
            menu.Add("edit", "Edit todo with id", () => {
                try {
                    TODOList l   = OpenList();
                    TODOEntity e = EntityById(l);
                    Console.WriteLine(e.ToString());
                    TODOEntity newEntity = NewEntityDialog();
                    newEntity.ID         = e.ID;

                    l.Update(newEntity);
                    l.Save();
                    return("\r\nTask successfully updated\r\n");
                }
                catch (Exception e) {
                    Console.WriteLine(e);
                    return("Fail");
                }
            });
            menu.Add("remove", "Remove todo with id from list", () => {
                try {
                    TODOList l   = OpenList();
                    TODOEntity e = EntityById(l);
                    Console.WriteLine(e.ToString());
                    l.Remove(e);
                    return("\r\nSuccessfully removed");
                }
                catch (Exception e) {
                    Console.WriteLine(e);
                    return("\r\nFail");
                }
            });
            menu.Add("showall", "Show all todos", () => {
                try {
                    OpenList().Print();
                    Console.WriteLine("\r\nPress enter to return to the menu.");
                    Console.Read();
                    return("\r\nSuccessfully printed all todos\r\n");
                }
                catch (Exception e) {
                    Console.WriteLine(e);
                    return("\r\nFail");
                }
            });
            menu.Start();
        }