﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using TarsimAVLBll;
using TarsimAvlCL;

namespace TarsimAvl.WebService
{
    /// <summary>
    /// Summary description for SimCard
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
     [System.Web.Script.Services.ScriptService]
    public class SimCard : System.Web.Services.WebService
    {


        [WebMethod]
        public SimCardList GetList(SimCardFilter obj)
        {
            if (obj.OrderBy == null || obj.OrderBy == "")
            {
                obj.OrderBy = "SimID";
                obj.Order = "desc";
            }

            var ds = TarsimBL.GetFilteredSimCard(obj);
            if (ds != null)
            {
                ds.PageIndex = obj.PageIndex;
                ds.PageSize = obj.PageSize;
            }
            return ds;
        }

        [WebMethod]
        public string Save(TarsimAvlCL.SimCard cl)
        {

            int i = TarsimAVLBll.TarsimBL.CreateSimCard(cl);
            if (i == 0)
            {
                return "خطا";
            }
            else
            {
                return i.ToString();
            }
        }


        [WebMethod]
        public string Edit(TarsimAvlCL.SimCard cl)
        {

            bool? i = TarsimAVLBll.TarsimBL.UpdateSimCard(cl);
            if (i ==null || i == false)
            {
                return "خطا";
            }
            else
            {
                return i.ToString();
            }
        }

        [WebMethod]
        public string Delete(TarsimAvlCL.SimCard cl)
        {
            return TarsimBL.DeleteSimCard(Convert.ToInt32(cl.SimID)).ToString();
        }
    }
}
