Пример #1
0
        public async Task <IActionResult> equipment(m_equipment device)
        {
            if (await repo.GetEquipment(device.EquipmentID) != null)
            {
                return(BadRequest("equipment already exists"));
            }
            var created = await repo.CreateEquipment(device);

            return(Ok(created));
        }
Пример #2
0
        public async Task <m_equipment> CreateEquipment(m_equipment device)
        {
            device.createdOn = DateTime.Now;
            device.isEnabled = true;
            var new_log = await _context.m_equipment.AddAsync(device);

            await _context.SaveChangesAsync();

            return(new_log.Entity);
        }
Пример #3
0
        public async Task <m_equipment> UpdateEquipment(m_equipment device)
        {
            var result = await _context.m_equipment.FirstOrDefaultAsync(e => e.EquipmentID == device.EquipmentID);

            result.EquipmentID = device.EquipmentID;
            result.Text        = device.Text;
            result.GeoLoc      = device.GeoLoc;
            result.Plant       = device.Plant;
            result.Workcenter  = device.Workcenter;
            result.modifiedOn  = DateTime.Now;
            result.isEnabled   = device.isEnabled;
            result.modifiedBy  = device.modifiedBy;
            await _context.SaveChangesAsync();

            return(result);
        }
Пример #4
0
        public async Task <IActionResult> equipmentupdate(m_equipment device)
        {
            var created = await repo.UpdateEquipment(device);

            return(Ok(created));
        }