using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Met_Fam
{
    public partial class Goods
    {
        private string typeOfGoods;

        public string TypeOfGoods
        {
            get { return typeOfGoods; }
            set { typeOfGoods = value; }
        }
    }
    public class ViewModel
    {
        public List<Goods> gds;
        public ViewModel()
        {
            gds = product();
        }

        public List<Goods> product()
        {
            List<Goods> goods = new List<Goods>();
            Goods buff;
            List<Goods> bdgoods = DataBase.BaseModel.Goods.ToList();

            foreach (Goods good in bdgoods)
            {
                buff = new Goods();
                buff.ID_Goods = good.ID_Goods;
                buff.Title_Goods = good.Title_Goods;
                buff.Price_Goods = good.Price_Goods;
                buff.Buying_Goods = good.Buying_Goods;
                buff.Picture = good.Picture;
                buff.Description = good.Description;
                buff.ID_Type_Goods = good.ID_Type_Goods;

                Type_Goods type_Goods = DataBase.BaseModel.Type_Goods.FirstOrDefault(x => x.ID_Type_Goods == good.ID_Type_Goods);
                buff.TypeOfGoods = type_Goods.Title_Type_Goods;

                goods.Add(buff);
            }
            return goods;
        }
    }
    public class ViewModel2
    {
        public List<User> usr;
        public ViewModel2()
        {
            usr = newuser();
        }

        public List<User> newuser()
        {
            List<User> users = new List<User>();
            User buff;
            List<User> bdusers = DataBase.BaseModel.User.ToList();

            foreach (User user in bdusers)
            {
                buff = new User();
                buff.ID_User = user.ID_User;
                buff.Surname_User = user.Surname_User;
                buff.Name_User = user.Name_User;
                buff.Login_User = user.Login_User;
                buff.Password_User = user.Password_User;
                buff.Phone_User = user.Phone_User;
                buff.Address = user.Address;
                buff.ID_Role = user.ID_Role;



                users.Add(buff);
            }
            return users;
        }
    }
}