﻿using System;
using System.Collections.Generic;
using Ziemianski.SimpleBlogPlatform.BlogApi.Interfaces;
using Ziemianski.SimpleBlogPlatform.Common;
using Ziemianski.SimpleBlogPlatform.Model.Models;

namespace Ziemianski.SimpleBlogPlatform.BlogApi.Implemention
{
    internal class UserOperationsImplementation : IUserOperations
    {
        public void AddFile(File file)
        {
            using (var ctx = new DataContext())
            {
                ctx.Files.Add(file);
                ctx.SaveChanges().CheckRecordHasBeenSaved();
            }
        }

        public void AddPost(Post post)
        {
            throw new NotImplementedException();
        }

        public void AddSiteField(SiteField field)
        {
            throw new NotImplementedException();
        }

        public void AddUser(User user)
        {
            user.Password = HashFunctions.CreateMD5(user.Password);
            using (var ctx = new DataContext())
            {
                ctx.Users.Add(user);
                ctx.SaveChanges().CheckRecordHasBeenSaved();
            }
        }

        public User GetUser(Guid id)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<User> GetUsers()
        {
            throw new NotImplementedException();
        }

        public void RemovePost(int id)
        {
            throw new NotImplementedException();
        }

        public void RemoveUser(Guid id)
        {
            throw new NotImplementedException();
        }

        public void UpdatePost(Post post)
        {
            throw new NotImplementedException();
        }
    }
}