Beispiel #1
0
        public void Create(ListToDo listToDo)
        {
            ListToDo lis = new ListToDo(listToDo.NomeItem, listToDo.DescricaoItem);

            _db.ListToDos.Add(lis);
            _db.SaveChanges();
        }
Beispiel #2
0
        public void Finaliza(int id)
        {
            ListToDo lis = Get(id);

            lis.Status        = "Concluido";
            lis.DataConclusao = DateTime.Now.Date;

            UpDate(lis);
        }
Beispiel #3
0
        private void PersistNewItems(ListToDoUse model, ListToDo listToDo)
        {
            ///Adding new items
            var itemsToAdd = model.Items
                             .Where(x => x.Id == 0)
                             .ToArray();

            var dbNewItems = itemsToAdd.Select(x => new ListToDoItem
            {
                ListToDoId = listToDo.Id,
                Comment    = x.Comment,
                Content    = x.Content,
                Status     = x.Status,
                Order      = x.Order,
            })
                             .ToArray();

            context.ListToDoItems.AddRange(dbNewItems);
        }
Beispiel #4
0
        private void Row_DoubleClick(object sender, RoutedEventArgs e)
        {
            DataGridRow row    = sender as DataGridRow;
            int         listId = ((SumList)row.DataContext).ID;

            if (Db.GetToDoesForGrid(listId).Count > 0)
            {
                ListToDo w = new ListToDo(listId);
                w.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("You don't have any 'ToDo' for this list.");
            }


            SetDoubleClickEvent();
        }
Beispiel #5
0
        private void VerifyListToSaveBelongsToUser(ListToDoUse model, string username, out ListToDo listToDo)
        {
            listToDo = context.ListsTodo.SingleOrDefault(x => x.Id == model.Id);
            if (listToDo == null)
            {
                throw new ItemNotFound("The list you are trying to modify does not exist!");
            }

            var userId = context.Users.SingleOrDefault(x => x.UserName == username)?.Id;

            if (userId == null)
            {
                throw new UserNotFound(username);
            }

            if (listToDo.UserId != userId)
            {
                throw new AccessDenied("The list you are trying to modify does not beling to you!");
            }
        }
Beispiel #6
0
 public void UpDate(ListToDo listToDo)
 {
     _db.Entry <ListToDo>(listToDo).State = System.Data.Entity.EntityState.Modified;
     _db.SaveChanges();
 }