Ejemplo n.º 1
0
        /// <summary>
        /// RestoreEquip - returns EquipmentCollectionDto - calls Rosettian UpdateEquipment method to reset data
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        protected static EquipmentCollectionDto RestoreEquip(EquipmentCriteriaDto criteria)
        {
            using (var client = new RosettianClient())
            {
                if (!client.ONTExists(criteria.SerialNumber, user))
                {
                    client.CreateONT(criteria, user);
                }
                var equipList =
                    client.SearchEquipment(new SearchFieldsDto {EquipmentId = criteria.SerialNumber}, user)
                        .Where(x => x.SerialNumber.Substring(0, x.SerialNumber.Length - 3) == criteria.SerialNumber).ToList();

                foreach (var equip in equipList.Where(x => x.LocationId != criteria.LocationId || x.Status != criteria.Status || x.UnitAddress != criteria.UnitAddress))
                {
                    equip.LocationId = criteria.LocationId;
                    equip.Status = criteria.Status;
                    equip.UnitAddress = criteria.UnitAddress;
                    client.UpdateEquipment(equip, user);
                }
                return new EquipmentCollectionDto(equipList);
            }
        }