public IHttpActionResult Putdevicetype(int id, devicetype devicetype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != devicetype.ID) { return(BadRequest()); } db.Entry(devicetype).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!devicetypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getdevicetype(int id) { devicetype devicetype = db.devicetypes.Find(id); if (devicetype == null) { return(NotFound()); } return(Ok(devicetype)); }
public IHttpActionResult Postdevicetype(devicetype devicetype) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.devicetypes.Add(devicetype); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = devicetype.ID }, devicetype)); }
public IHttpActionResult Deletedevicetype(int id) { devicetype devicetype = db.devicetypes.Find(id); if (devicetype == null) { return(NotFound()); } db.devicetypes.Remove(devicetype); db.SaveChanges(); return(Ok(devicetype)); }
public ResultHelper SetDeviceType(DeviceTypeDto deviceTypeDto) { try { devicetype item = new devicetype(); item.DeviceTypeID = deviceTypeDto.DeviceTypeID; item.Name = deviceTypeDto.Name; using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.GetRepository <devicetype>().Update(item); unitOfWork.saveChanges(); return(new ResultHelper(true, item.DeviceTypeID, ResultHelper.SuccessMessage)); } } catch (Exception ex) { return(new ResultHelper(false, 0, ResultHelper.UnSuccessMessage)); } }
public DeviceTypeDto GetDeviceType(int deviceTypeID) { try { using (UnitOfWork unitofWork = new UnitOfWork()) { devicetype item = new devicetype(); item = unitofWork.GetRepository <devicetype>().GetById(x => x.DeviceTypeID == deviceTypeID); DeviceTypeDto deviceTypeDto = new DeviceTypeDto(); deviceTypeDto.DeviceTypeID = item.DeviceTypeID; deviceTypeDto.Name = item.Name; return(deviceTypeDto); } } catch (Exception ex) { return(null); } }