Exemple #1
0
        public async Task <IActionResult> PutTodoItem(long id, TodoItem todoItem)
        {
            if (id != todoItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(todoItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TodoItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <dynamic> > CreateAccount([FromBody] User user)
        {
            var alreadyExists = await _context.User.Where(x => x.Email == user.Email).FirstOrDefaultAsync();

            if (alreadyExists != null)
            {
                return(BadRequest(new { message = "Email already exists!" }));
            }



            user.Password = CrypterService.HashPassword(user.Password);

            _context.User.Add(user);

            await _context.SaveChangesAsync();

            return(user);
        }
Exemple #3
0
 public async Task store(TodoItem todoItem)
 {
     _context.TodoItem.Add(todoItem);
     await _context.SaveChangesAsync();
 }
 public async Task CreateProject(Project project)
 {
     _context.Project.Add(project);
     await _context.SaveChangesAsync();
 }