Exemplo n.º 1
0
        public async Task <IActionResult> DelCompetence(int id)
        {
            var comp = await _context.Competences.FindAsync(id);

            if (comp != null)
            {
                _context.Remove(comp);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "competence supprimée avec succée !"
                }));
            }
            return(NotFound());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DelLangue(int id)
        {
            var langue = await _context.Langues.FindAsync(id);

            if (langue != null)
            {
                _context.Remove(langue);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "langue supprimée avec succée !"
                }));
            }
            return(NotFound());
        }
Exemplo n.º 3
0
        public ActionResult DeleteTodoItem(long id)

        {
            try

            {
                var todo = todoDb.TodoItems.FirstOrDefault(t => t.Id == id);

                if (todo != null)

                {
                    todoDb.Remove(todo);

                    todoDb.SaveChanges();
                }
            }

            catch (Exception e)

            {
                return(BadRequest(e.InnerException.Message));
            }

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task RemoveTodoAsync(int id)
        {
            var todo = await _todoContext.Todos.FindAsync(id);

            _todoContext.Remove(todo);
            await _todoContext.SaveChangesAsync();
        }
 public async Task Remove(TodoItem item)
 {
     using ILifetimeScope nested = scope.BeginLifetimeScope();
     using TodoContext context   = nested.Resolve <TodoContext>();
     context.Remove(item);
     await context.SaveChangesAsync();
 }
Exemplo n.º 6
0
        public void Remove(string id)
        {
            var todoToRemove = TodoContext.Todos.FirstOrDefault(t => t.Id == int.Parse(id));

            TodoContext.Remove(todoToRemove);
            TodoContext.SaveChanges();
        }
Exemplo n.º 7
0
        public async Task <IActionResult> logout([FromBody] RefreshToken reft, string id)
        {
            Candidat user = (Candidat)await userManager.FindByIdAsync(id);

            if (user != null)
            {
                var savedRefreshToken = user.RefreshTokens.Where(x => x.refresh_token == reft.refresh_token &&
                                                                 x.access_token == reft.access_token).FirstOrDefault();
                Console.WriteLine(savedRefreshToken == null);
                Console.WriteLine(reft.access_token);
                Console.WriteLine(reft.refresh_token);
                if (savedRefreshToken != null)
                {
                    _context.Remove(savedRefreshToken);
                    _context.SaveChanges();
                    return(Ok(new { msg = "success !" }));
                }
                else
                {
                    return(StatusCode(404));
                }
            }
            else
            {
                return(StatusCode(403));
            }
        }
Exemplo n.º 8
0
        public void TestCRUD()
        {
            Assert.False(_context.Item.Where(w => w.Id == GuidIdTest).Any());

            _context.Item.Add(new todo_db.Models.Item
            {
                Id         = GuidIdTest,
                Name       = "ToDo Test",
                IsComplete = false
            });
            _context.SaveChanges();

            Assert.True(_context.Item.Where(w => w.Id == GuidIdTest).Any());

            var itemAdded = _context.Item.Where(w => w.Id == GuidIdTest).Single();

            itemAdded.IsComplete = true;

            _context.SaveChanges();

            Assert.False(_context.Item.Where(w => w.Id == GuidIdTest && !w.IsComplete).Any());

            var itemToDelete = _context.Item.Where(w => w.Id == GuidIdTest).Single();

            _context.Remove(itemToDelete);

            _context.SaveChanges();

            Assert.False(_context.Item.Where(w => w.Id == GuidIdTest).Any());
        }
Exemplo n.º 9
0
            public async Task <Unit> Handle(Command c, CancellationToken ct)
            {
                if (c is null)
                {
                    throw new ArgumentNullException(nameof(c));
                }

                var strategy = _context.Database.CreateExecutionStrategy();

                await strategy.ExecuteAsync(async (ct) => {
                    var existingTodo = await _context.Todos.SingleOrDefaultAsync(x => x.Id == c.Id, ct).ConfigureAwait(false);

                    if (existingTodo is null)
                    {
                        throw new RestException(
                            System.Net.HttpStatusCode.NoContent,
                            new Models.ErrorResponse[] {
                            new Models.ErrorResponse {
                                Error   = Models.ErrorCodes.E_OBJECT_NOT_FOUND,
                                Message = $"Cannot find todo with ID [{c.Id}]"
                            }
                        }
                            );
                    }

                    _context.Remove(existingTodo);

                    await _context.SaveChangesAsync(ct).ConfigureAwait(false);
                }, ct).ConfigureAwait(false);

                return(Unit.Value);
            }
Exemplo n.º 10
0
        private void UpdateTodoTags(IEnumerable <string> selectedTags, TodoItem todoItem)
        {
            var newTags     = new HashSet <string>(selectedTags);
            var currentTags = new HashSet <string>(todoItem.TagAssignments.Select(t => t.TagName));

            foreach (var tag in _context.Tags)
            {
                if (newTags.Contains(tag.Name))
                {
                    if (!currentTags.Contains(tag.Name))
                    {
                        todoItem.TagAssignments.Add(
                            new TagAssignment {
                            TodoId = todoItem.Id, TagName = tag.Name
                        });
                    }
                }
                else
                {
                    if (currentTags.Contains(tag.Name))
                    {
                        var tagAssignment = todoItem.TagAssignments.FirstOrDefault(t => t.TagName == tag.Name);
                        _context.Remove(tagAssignment);
                    }
                }
            }
        }
        public async Task <ActionResult <IEnumerable <Candidature> > > deleteCandidature(int id)
        {
            // var user = await userManager.FindByIdAsync(id);
            var candidature = await _context.Candidatures.FindAsync(id);

            if (candidature != null)
            {
                _context.Remove(candidature);
                _context.Remove(candidature);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "Candidature supprimé avec succée !"
                }));
            }
            return(NotFound());
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Delete(int id)
        {
            var todoItem = await _todoContext.TodoItems.FirstOrDefaultAsync(m => m.Id == id);

            _todoContext.Remove(todoItem);
            await _todoContext.SaveChangesAsync();

            return(Ok(todoItem));
        }
        public async Task ExecuteAsync(DeleteTodoItemCommand deleteTodoItemCommand)
        {
            await _deleteTodoItemCommandValidator.AssertValidAsync(deleteTodoItemCommand);

            var todoItem = await _todoItemQueries.GetTodoItemById(deleteTodoItemCommand.Id);

            _todoContext.Remove(todoItem);
            await _todoContext.SaveChangesAsync();
        }
Exemplo n.º 14
0
 public void DeleteToDo(long id)
 {
     foreach (var item in toDoContext.ToDos)
     {
         if (item.Id == id)
         {
             toDoContext.Remove(item);
         }
     }
     toDoContext.SaveChanges();
 }
Exemplo n.º 15
0
        public void Delete(Guid id)
        {
            var user = _context.Users.FirstOrDefaultAsync(u => u.Id == id);

            if (user == null)
            {
                throw new UserNotFoundException(id.ToString());
            }

            _context.Remove(user);
        }
Exemplo n.º 16
0
        public Todo Remove(int id)
        {
            var item = _todoContext.Todo.Find(id + "");

            if (item == null)
            {
                throw new Exception("Not found");
            }
            _todoContext.Remove(item);
            _todoContext.SaveChanges();
            return(item);
        }
Exemplo n.º 17
0
        public async Task Delete(int id)
        {
            var entity = await _context.Todos.FindAsync(id);

            if (entity == null)
            {
                return;
            }

            _context.Remove(entity);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 18
0
        public async Task <TodoItem> DeleteTodoItem(long id)
        {
            TodoItem itemToDelte = await _context.TodoItems.FindAsync(id);

            if (itemToDelte == null)
            {
                return(null);
            }
            _context.Remove(itemToDelte);
            await _context.SaveChangesAsync();

            return(itemToDelte);
        }
Exemplo n.º 19
0
        public IActionResult Delete(long id)
        {
            var todo = todoContext.TodoItems.FirstOrDefault(t => t.Id == id);

            if (todo == null)
            {
                return(NotFound());
            }
            todoContext.Remove(todo);
            todoContext.SaveChanges();

            return(new NoContentResult());
        }
Exemplo n.º 20
0
        public IActionResult Delete(string id)
        {
            TodoItem todo = _dbContext.TodoItems.SingleOrDefault(t => t.TodoItemID == id);

            if (todo == null)
            {
                return(NotFound());
            }

            _dbContext.Remove(id);
            _dbContext.SaveChanges();
            return(new NoContentResult());
        }
Exemplo n.º 21
0
        public async Task <IActionResult> Delete(int id)
        {
            TodoItem temp = await context.toDoItems.FindAsync(id);

            if (temp == null)
            {
                return(NotFound("Object not found, Id: " + id));
            }
            context.Remove(temp);
            await context.SaveChangesAsync();

            return(Ok());
        }
        public async Task <IActionResult> Delete(long id)
        {
            var todoItem = await _context.TodoItems.FindAsync(id);

            if (todoItem == null)
            {
                return(NotFound());
            }
            _context.Remove(todoItem);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 23
0
        public ActionResult <TodoItem> DeleteTodoItem(long Id)
        {
            var todoItem = _context.TodoItems.Find(Id);

            if (todoItem == null)
            {
                return(NotFound());
            }

            _context.Remove(todoItem);
            _context.SaveChanges();
            return(todoItem);
        }
Exemplo n.º 24
0
 public void DeleteUser(long id)
 {
     foreach (var user in toDoContext.Users)
     {
         if (user.UserId == id)
         {
             if (user.ToDos.Count() == 0 && user.CreatedToDos.Count() == 0)
             {
                 toDoContext.Remove(user);
             }
         }
     }
     toDoContext.SaveChanges();
 }
Exemplo n.º 25
0
        public async Task <IActionResult> DeleteCategory(long id)
        {
            var category = await _context.Categories.FindAsync(id);

            if (category == null)
            {
                return(NotFound());
            }

            _context.Remove(category);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 26
0
        public async Task <IActionResult> DeleteFlow(long id)
        {
            var flow = await _context.Flows.FindAsync(id);

            if (flow == null)
            {
                return(NotFound());
            }

            _context.Remove(flow);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <IActionResult> DelQuestionnaire(int id)
        {
            var question = await _context.Questions.FindAsync(id);

            if (question != null)
            {
                _context.Remove(question);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "question supprimée avec succée !"
                }));
            }
            return(NotFound());
        }
Exemplo n.º 28
0
        public async Task <IActionResult> DelReponse(int id)
        {
            var reponse = await _context.Reponses.FindAsync(id);

            if (reponse != null)
            {
                _context.Remove(reponse);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "Reponse supprimée avec succée !"
                }));
            }
            return(NotFound());
        }
        public async Task <IActionResult> DelFormation(int id)
        {
            var formation = await _context.Formations.FindAsync(id);

            if (formation != null)
            {
                _context.Remove(formation);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "formation supprimée avec succée !"
                }));
            }
            return(NotFound());
        }
Exemplo n.º 30
0
        public async Task <IActionResult> DelCompetence(int id)
        {
            var hobby = await _context.Hobbies.FindAsync(id);

            if (hobby != null)
            {
                _context.Remove(hobby);
                _context.SaveChanges();
                return(Ok(new
                {
                    msg = "Hobby supprimé avec succée !"
                }));
            }
            return(NotFound());
        }