Exemplo n.º 1
0
        public HttpResponseMessage Post([FromBody] DriverBO driverBO)
        {
            Data.driver _driver = new Data.driver();

            //_driver.driverkey = driverBO.DriverKey;
            _driver.firstname                = driverBO.FirstName;
            _driver.lastname                 = driverBO.LastName;
            _driver.driverid                 = driverBO.DriverId;
            _driver.drivinglicenseno         = driverBO.DriversLicenseNo;
            _driver.drivinglicenseexpirydate = driverBO.LicenseExpiryDate;
            _driver.vendkey = driverBO.VendorKey;

            _driver.createdate = DateTime.Now;
            _driver.status     = 1;
            _driver.statusdate = DateTime.Now;

            if (driverBO.Address != null)
            {
                var custaddress = new Data.address()
                {
                    address1 = driverBO.Address.Address1,
                    address2 = driverBO.Address.Address2,
                    city     = driverBO.Address.City,
                    state    = driverBO.Address.State,
                    country  = driverBO.Address.Country,
                    zipcode  = driverBO.Address.Zip,
                    email    = driverBO.Address.Email,
                    fax      = driverBO.Address.Fax,
                    addrname = _driver.driverid
                };
                var addrkey = new AddressRepository().Add(custaddress);
                _driver.addrkey = addrkey;
            }
            Guid custId = repo.Add(_driver);

            if (custId != null && custId != Guid.Empty)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, custId, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage Put([FromBody] DriverBO driverBO)
        {
            Data.driver _customer = new Data.driver();
            _customer.driverkey                = driverBO.DriverKey;
            _customer.firstname                = driverBO.FirstName;
            _customer.lastname                 = driverBO.LastName;
            _customer.driverid                 = driverBO.DriverId;
            _customer.drivinglicenseno         = driverBO.DriversLicenseNo;
            _customer.drivinglicenseexpirydate = driverBO.LicenseExpiryDate;
            _customer.vendkey = driverBO.VendorKey;

            if (driverBO.Address != null)
            {
                var custaddress = new Data.address()
                {
                    addrkey  = driverBO.Address.AddrKey,
                    address1 = driverBO.Address.Address1,
                    address2 = driverBO.Address.Address2,
                    city     = driverBO.Address.City,
                    state    = driverBO.Address.State,
                    country  = driverBO.Address.Country,
                    zipcode  = driverBO.Address.Zip,
                    email    = driverBO.Address.Email,
                    fax      = driverBO.Address.Fax,
                    addrname = _customer.firstname
                };
                bool updated = new AddressRepository().Update(custaddress);
            }


            bool result = repo.Update(_customer);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage GetDriverByID(string driverkey)
        {
            Data.driver driver   = repo.GetbyId(Guid.Parse(driverkey));
            DriverBO    driverBO = new DriverBO();

            if (driver != null)
            {
                //DriverBO driverBO = new DriverBO();

                driverBO.DriverKey         = driver.driverkey;
                driverBO.FirstName         = driver.firstname;
                driverBO.LastName          = driver.lastname;
                driverBO.DriverId          = driver.driverid;
                driverBO.DriversLicenseNo  = driver.drivinglicenseno;
                driverBO.LicenseExpiryDate = driver.drivinglicenseexpirydate;
                driverBO.VendorKey         = driver.vendkey;

                var address = new AddressRepository().GetbyId(driver.addrkey);
                driverBO.Address = new AddressBO()
                {
                    AddrKey  = address.addrkey,
                    Address1 = address.address1,
                    Address2 = address.address2,
                    City     = address.city,
                    State    = address.state,
                    Zip      = address.zipcode,
                    Email    = address.email,
                    Phone    = address.phone,
                    Fax      = address.fax
                };
                //driverBO.Add(driverBO);

                return(Request.CreateResponse(HttpStatusCode.OK, driverBO, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Not found", Configuration.Formatters.JsonFormatter));
            }
        }