Esempio n. 1
0
        public APIResponse Put(int id, [FromBody] ViewTerminalDetail model) //[FromBody]JObject model
        {
            APIResponse response = new APIResponse();

            if (model == null || model.ID != id)
            {
                response.Error = 1;
                return(response);
            }

            var item = _context.ViewTerminalDetail.FirstOrDefault(m => m.ID == id);

            if (item == null)
            {
                response.Error = 2;
                return(response);
            }

            item.IMEI            = model.IMEI;
            item.MAC             = model.MAC;
            item.FirmwareVersion = model.FirmwareVersion;
            //item.GroupID = model.GroupID;
            item.BDLocation     = model.BDLocation;
            item.ModelNumber    = model.ModelNumber;
            item.ReceiveHost    = model.ReceiveHost;
            item.ReceiveTCPPort = model.ReceiveTCPPort;
            item.ReceiveUDPPort = model.ReceiveUDPPort;
            item.Status         = model.Status;
            item.TypeID         = model.TypeID;
            item.Address        = model.Address;

            _context.ViewTerminalDetail.Update(item);
            _context.SaveChanges();
            return(response);
        }
Esempio n. 2
0
        public APIResponse Post([FromBody] ViewTerminalDetail model)
        {
            APIResponse response = new APIResponse();

            if (model == null)
            {
                response.Error = 1;
                return(response);
            }
            model.AddDate = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;
            _context.ViewTerminalDetail.Add(model);
            _context.SaveChanges();
            return(response);
        }