﻿using Sharepoint.Client.Fluent.Exceptions;
using Sharepoint.Client.Fluent.Exceptions.Interactors;
using Sharepoint.Client.Fluent.FluentBase;
using SP = Microsoft.SharePoint.Client;

namespace Sharepoint.Client.Fluent.Lists.Operations
{
    public class SharepointRetrievedListOperations : SharepointFluentBase
    {
        private SP.List sharepointList;

        internal SharepointRetrievedListOperations(SP.List list, ISharepointContext context) : base(context)
        {
            ExceptionFactory.GetInteractor<NullCheckInteractor>()
                .CheckForConstructorArgumentNull(list, nameof(list), typeof(SharepointRetrievedListOperations));

            this.sharepointList = list;
        }

        public SharepointListGetOperations Get
        {
            get
            {
                var listGet = new SharepointListGetOperations(this.sharepointList, this.sharepointContext);
                return listGet;
            }
        }

        public SharepointListAddOperations Add
        {
            get
            {
                return new SharepointListAddOperations(this.sharepointList, this.sharepointContext);
            }
        }

        public SharepointListUpdateOperations Update
        {
            get
            {
                return new SharepointListUpdateOperations(this.sharepointList, this.sharepointContext);
            }
        }

        public SharepointListDeleteOperations Delete
        {
            get { return new SharepointListDeleteOperations(this.sharepointList, this.sharepointContext); }
        }
    }
}