Beispiel #1
0
 public bool Equals(ICheckOutObject other)
 {
     return(ServerName == other.ServerName &&
            Login == other.Login &&
            ObjectOwner == other.ObjectOwner &&
            ObjectName == other.ObjectName &&
            ObjectType == other.ObjectType);
 }
        public bool ChecksBeforeCheckIn(IEnumerable <ICheckOutObject> list, ICheckOutObject checkInObject, out string ErrorMsg)
        {
            if (!CheckServer(checkInObject.ServerName, out ErrorMsg))
            {
                return(false);
            }

            if (!list.Contains(checkInObject))
            {
                var objName = $"{checkInObject.ObjectType} {checkInObject.ObjectOwner}.{checkInObject.ObjectName}";
                ErrorMsg = $"В настоящий момент вы не являетесь владельцем {objName}";
                return(false);
            }

            return(true);
        }
        public bool ChecksBeforeCheckOut(IEnumerable <ICheckOutObject> list, ICheckOutObject checkOutObject, out string ErrorMsg)
        {
            if (!CheckServer(checkOutObject.ServerName, out ErrorMsg))
            {
                return(false);
            }

            if (list.Any(x => x.ServerName == checkOutObject.ServerName &&
                         x.ObjectName == checkOutObject.ObjectName &&
                         x.ObjectOwner == checkOutObject.ObjectOwner &&
                         x.ObjectType == checkOutObject.ObjectType))
            {
                var ExistedCheckoutLogin = list.First(x => x.ServerName == checkOutObject.ServerName &&
                                                      x.ObjectName == checkOutObject.ObjectName &&
                                                      x.ObjectOwner == checkOutObject.ObjectOwner &&
                                                      x.ObjectType == checkOutObject.ObjectType).Login;
                ErrorMsg = $"Невозможно сделать CheckOut, объект находится в пользовании у {ExistedCheckoutLogin}";
                return(false);
            }

            return(true);
        }