// transfer model to data and update
        // links:
        //  docLink: http://sql2x.org/documentationLink/658fda50-2ad3-414e-9299-2b399d17a057
        public void Update(CrudeAircraftDocumentModel model)
        {
            var data = new CrudeAircraftDocumentData();

            ModelToData(model, data);
            data.Update();
        }
        // transfer model to data and update, on a transaction
        // links:
        //  docLink: http://sql2x.org/documentationLink/aa07e05b-edc8-4e09-bf93-bf2a40c93c09
        public void Update(CrudeAircraftDocumentModel model, SqlConnection connection, SqlTransaction transaction)
        {
            var data = new CrudeAircraftDocumentData();

            ModelToData(model, data);
            data.Update(connection, transaction);
        }
        // transfer model to data and insert
        // links:
        //  docLink: http://sql2x.org/documentationLink/17cd8423-3c78-459f-a45b-773fcfbc3b7d
        public void Insert(CrudeAircraftDocumentModel model)
        {
            var data = new CrudeAircraftDocumentData();

            ModelToData(model, data);
            data.Insert();
        }
        // fetch by Search key into current object
        // links:
        //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
        //  docLink: http://sql2x.org/documentationLink/ad2dd952-e3ec-471a-9e34-f5fc965b8b37
        // parameters:
        //  DocumentName: key of table CrudeAircraftDocumentData
        public CrudeAircraftDocumentModel FetchByDocumentName(string documentName)
        {
            var dataAccessLayer = new CrudeAircraftDocumentData();
            var model           = new CrudeAircraftDocumentModel();

            dataAccessLayer.FetchByDocumentName(documentName);
            DataToModel(dataAccessLayer, model);

            return(model);
        }
        // fetch by Primary key into current object
        // links:
        //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
        //  docLink: http://sql2x.org/documentationLink/fdcc33b4-08f1-43c3-ae28-95fbf029c3bd
        // parameters:
        //  CrudeAircraftDocumentData: primary key of table CrudeAircraftDocumentData
        public CrudeAircraftDocumentModel FetchByAircraftDocumentId(System.Guid aircraftDocumentId)
        {
            var dataAccessLayer = new CrudeAircraftDocumentData();
            var model           = new CrudeAircraftDocumentModel();

            dataAccessLayer.FetchByAircraftDocumentId(aircraftDocumentId);
            DataToModel(dataAccessLayer, model);

            return(model);
        }
 // transfer data object to model object
 // links:
 //  docLink: http://sql2x.org/documentationLink/43d57600-5ff5-4ef8-9330-123773d100d3
 public static void DataToModel(CrudeAircraftDocumentData data, CrudeAircraftDocumentModel model)
 {
     model.AircraftDocumentId      = data.AircraftDocumentId;
     model.AircraftId              = data.AircraftId;
     model.AircraftDocumentTypeRcd = data.AircraftDocumentTypeRcd;
     model.DocumentName            = data.DocumentName;
     model.DocumentDateTime        = data.DocumentDateTime;
     model.ExpiryDateTime          = data.ExpiryDateTime;
     model.UserId   = data.UserId;
     model.DateTime = data.DateTime;
 }
 // transfer model object to data object
 // links:
 //  docLink: http://sql2x.org/documentationLink/95875d99-b7f7-4a9e-baa4-3fbe9925d8a2
 public static void ModelToData(CrudeAircraftDocumentModel model, CrudeAircraftDocumentData data)
 {
     data.AircraftDocumentId      = model.AircraftDocumentId;
     data.AircraftId              = model.AircraftId;
     data.AircraftDocumentTypeRcd = model.AircraftDocumentTypeRcd;
     data.DocumentName            = model.DocumentName;
     data.DocumentDateTime        = model.DocumentDateTime;
     data.ExpiryDateTime          = model.ExpiryDateTime;
     data.UserId   = model.UserId;
     data.DateTime = model.DateTime;
 }
        // transfer data list to model list
        // links:
        //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
        //  docLink: http://sql2x.org/documentationLink/b8ab5693-f2f2-494f-883e-89b617113511
        // parameters:
        //  CrudeAircraftDocumentData: key of table CrudeAircraftDocumentData
        public static List <CrudeAircraftDocumentModel> DataListToModelList(List <CrudeAircraftDocumentData> dataList)
        {
            var modelList = new List <CrudeAircraftDocumentModel>();

            foreach (CrudeAircraftDocumentData data in dataList)
            {
                var model = new CrudeAircraftDocumentModel();
                DataToModel(data, model);
                modelList.Add(model);
            }

            return(modelList);
        }
        // fetch all from table into new List of class instances, filtered by any column
        // links:
        //  docLink: http://sql2x.org/documentationLink/db27658d-4d23-46d7-9970-7bbaef8634b0
        public List <CrudeAircraftDocumentModel> FetchWithFilter(System.Guid aircraftDocumentId, System.Guid aircraftId, string aircraftDocumentTypeRcd, string documentName, System.DateTime documentDateTime, System.DateTime expiryDateTime, System.Guid userId, System.DateTime dateTime)
        {
            var list = new List <CrudeAircraftDocumentModel>();
            List <CrudeAircraftDocumentData> dataList = CrudeAircraftDocumentData.FetchWithFilter(aircraftDocumentId, aircraftId, aircraftDocumentTypeRcd, documentName, documentDateTime, expiryDateTime, userId, dateTime);

            foreach (CrudeAircraftDocumentData data in dataList)
            {
                var crudeAircraftDocumentBusinessModel = new CrudeAircraftDocumentModel();
                DataToModel(data, crudeAircraftDocumentBusinessModel);
                list.Add(crudeAircraftDocumentBusinessModel);
            }

            return(list);
        }
        // fetch all rows from table with an offset, and limit of rows
        // links:
        //  docLink: http://sql2x.org/documentationLink/a87e5c54-b47e-4031-bc3b-837b4cf9f692
        public List <CrudeAircraftDocumentModel> FetchAllWithLimitAndOffset(string limit, string offset)
        {
            var list = new List <CrudeAircraftDocumentModel>();
            List <CrudeAircraftDocumentData> dataList = CrudeAircraftDocumentData.FetchAllWithLimitAndOffset(int.Parse(limit), int.Parse(offset));

            foreach (CrudeAircraftDocumentData crudeAircraftDocumentBusiness in dataList)
            {
                var model = new CrudeAircraftDocumentModel();
                DataToModel(crudeAircraftDocumentBusiness, model);
                list.Add(model);
            }

            return(list);
        }
        // copy all rows from a List of serialized data objects in CrudeAircraftDocumentData to a List of SOAP Contracts
        // links:
        //  docLink: http://sql2x.org/documentationLink/3d3e60c3-69e4-43d6-8bd5-14a67a6ecf58
        public List <CrudeAircraftDocumentModel> FetchAll()
        {
            var list = new List <CrudeAircraftDocumentModel>();
            List <CrudeAircraftDocumentData> dataList = CrudeAircraftDocumentData.FetchAll();

            foreach (CrudeAircraftDocumentData crudeAircraftDocumentBusiness in dataList)
            {
                var model = new CrudeAircraftDocumentModel();
                DataToModel(crudeAircraftDocumentBusiness, model);
                list.Add(model);
            }

            return(list);
        }
        public CrudeAircraftDocumentModel CrudeAircraftDocumentUpdate([Bind()] CrudeAircraftDocumentModel aircraftDocument)
        {
            new CrudeAircraftDocumentBusiness().Update(aircraftDocument);

            return(aircraftDocument);
        }
        public CrudeAircraftDocumentModel CrudeAircraftDocumentCreate([Bind()] CrudeAircraftDocumentModel aircraftDocument)
        {
            new CrudeAircraftDocumentBusiness().Insert(aircraftDocument);

            return(aircraftDocument);
        }