public async Task <IHttpActionResult> addLocation(GPSView.Models.Locations location)
        {
            var dm = new GPSView.Models.DB_Model();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            dm.Locations.Add(location);
            var add_res = await dm.SaveChangesAsync();

            if (add_res < 1)
            {
                return(BadRequest("Location is not added."));
            }

            return(Created("", location));
        }
Exemple #2
0
        public async Task <IHttpActionResult> addDevice(Models.Device device)
        {
            var dm = new GPSView.Models.DB_Model();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (dm.Device.Where(x => x.IMEI == device.IMEI).Count() > 0)
            {
                return(BadRequest("Device is already exists."));
            }
            dm.Device.Add(device);
            var add_res = await dm.SaveChangesAsync();

            if (add_res < 1)
            {
                return(BadRequest("Device is not added."));
            }
            return(Created("", device));
        }