﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using J.Models;
using J.DAL;
using X.Common;

namespace J.BLL
{
    public class MemberBLL
    {
        private MemberDAL dal;

        public MemberBLL()
        {
            dal = new MemberDAL();
        }
                
        #region info

        public MemberModel Signup(MemberModel model)
        {
            model.Pwd = Utils.MD5(model.Pwd);
            return dal.Signup(model);
        }

        public MemberModel Signin(MemberModel model)
        {
            model.Pwd = Utils.MD5(model.Pwd);
            return dal.Signin(model);
        }

        #endregion

        #region address

        public int AddAddress(AddressModel model)
        {
            return dal.AddAddress(model);
        }

        public int ModifyAddress(AddressModel model)
        {
            return dal.ModifyAddress(model);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">地址ID</param>
        /// <returns></returns>
        public AddressModel GetAddressInfoByID(int id)
        {
            return GetAddressInfoByID(id, -1);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">地址ID</param>
        /// <param name="memberid">会员ID</param>
        /// <returns></returns>
        public AddressModel GetAddressInfoByID(int id, int memberid)
        {
            return dal.GetAddressInfoByID(id, memberid);
        }

        public IList<AddressModel> GetMemberAddressList(int memberid)
        {
            return dal.GetMemberAddressList(memberid);
        }

        public int DelAddress(int id)
        {
            return DelAddress(id, -1);
        }

        public int DelAddress(int id, int memberid)
        {
            return dal.DelAddress(id, memberid);
        }

        public int SetMemberDefaultAddress(int id, int memberid)
        {
            return dal.SetMemberDefaultAddress(id, memberid);
        }

        #endregion

    }
}
