Exemplo n.º 1
0
        public async Task <Person> Add(Person person)
        {
            _context.Add(person);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(person);
        }
Exemplo n.º 2
0
        public async Task <Category> Agregar(Category category)
        {
            category.Condition = true;
            _context.Add(category);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(category);
        }
Exemplo n.º 3
0
        public async Task <Role> AddRole(Role role)
        {
            role.Condition = true;

            _context.Add(role);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(role);
        }
Exemplo n.º 4
0
        public async Task <Article> AddArticle(Article article)
        {
            article.Condition = true;

            _context.Add(article);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(null);
            }

            var category = await _categoryRepository.ObtenerCategoryAsync(article.idCategory);

            article.Category = category;

            return(article);
        }
Exemplo n.º 5
0
        public async Task <User> AddUser(User user)
        {
            user.Condition = true;



            _context.Add(user);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(null);
            }

            var role = await _roleRepository.ObtainRoleAsync(user.idRole);

            user.Role = role;
            return(user);
        }