public async Task <bool> DeleteEquipmentType(long equipmentTypeId) { var equipmentType = await EquipmentTypeAccessor.GetEquipmentType(equipmentTypeId); equipmentType.Deleted = true; try { await EquipmentTypeAccessor.SaveEquipmentType(equipmentType); Logger.Log(string.Format("Equipment type deleted - Id: {0}", equipmentTypeId), TraceEventType.Information); // update the equipment type for existing equipment with the deleted type var equipments = await EquipmentAccessor.GetEquipmentByType(equipmentTypeId); foreach (var equipment in equipments) { try { equipment.EquipmentTypeId = 1; await EquipmentAccessor.SaveEquipment(equipment); } catch (Exception ex) { Logger.Log(string.Format("Could not reassign equipment Type - EquipmentId: {0}", equipment.EquipmentId), TraceEventType.Error, ex); } } return(true); } catch (Exception ex) { Logger.Log("Could not delete equipment type", TraceEventType.Error, ex); return(false); } }
public void EquipmentAccessor_GetEquipmentByType_Empty() { accessor = GetAccessor(); var res = accessor.GetEquipmentByType(99).Result; Assert.IsNotNull(res); Assert.AreEqual(0, res.Count()); }
public void EquipmentAccessor_GetEquipmentByType() { accessor = GetAccessor(); var res = accessor.GetEquipmentByType(1).Result; Assert.IsNotNull(res); Assert.AreEqual(3, res.Count()); Assert.AreEqual(typeof(List <Equipment>), res.GetType()); Assert.AreEqual("Name 1", res.First().Name); }
public async Task <IEnumerable <Equipment> > GetEquipmentByType(long equipmentTypeId) { return(await EquipmentAccessor.GetEquipmentByType(equipmentTypeId)); }