Exemple #1
0
        /// <summary>
        /// try to create a user if it goes through return a true otherwise return a flase
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <int> CreateUser(User user)
        {
            try {
                var newUser = DbEntityConverter.ToUserEntity(user); // convert
                await _context.AddAsync(newUser);

                await _context.SaveChangesAsync();

                return(newUser.Id);
            } catch {
                return(-1);
            }
        }
Exemple #2
0
        public async Task <int> CreatePostAsync(Post post)
        {
            try
            {
                var newPost = DbEntityConverter.ToPostEntity(post);
                await _context.AddAsync(newPost);

                await _context.SaveChangesAsync();

                return(newPost.Id);
            }
            catch
            {
                return(-1);
            }
        }